thx Nick - I was trying to do a mouseover effect for menus that I could put in a class and so reuse. I got it down now. If you weant the code here it is. Put it in a class module
Option Explicit
Private PreviousControl As String
Private CurrentForm As Form
Private MenuControls() As String
Private MenuItems As Integer
Private MenuFocus() As String
Public Sub SetMouseOver(CurrentControl As String, Optional FocusControl As String, Optional HelpControl As String, Optional HelpText As String)
On Error Resume Next
'clear the board
ClearMenu
'Do what you want to the control that has the mouse over it
With CurrentForm(CurrentControl)
.FontBold = 1
End With
'Set the focus to any passed control
If IsNull(FocusControl) = False Then
CurrentForm(FocusControl).SetFocus
End If
'Set the help text to any passed label
If IsNull(HelpControl) = False Then
CurrentForm(HelpControl).Caption = HelpText
End If
'Add the control to the menu array
AddMenuControl CurrentControl
'Set the previous control
PreviousControl = CurrentControl
End Sub
Public Sub RemoveMouseOver()
'Take off mouseover
ClearMenu
End Sub
Private Sub ClearMenu()
Dim i As Integer
On Error Resume Next
'Loop through all controls and remove any mouseover effect
For i = 0 To (MenuItems - 1)
With CurrentForm(MenuControls(i))
.FontBold = 0
End With
Next i
End Sub
Public Static Property Let ActiveForm(ByVal FormObject As Form)
'Set which is the active form affected
Set CurrentForm = Nothing
Set CurrentForm = FormObject
End Property
Private Sub AddMenuControl(Control As String)
Dim i As Integer
Dim cycleitems As Integer
Dim ExistingControl As Boolean
'Loop through the passed control and add it to this array if it isn't there already
'This array is used to ensure that the mouseover effect is removed from all controls
'That no longer should have the effect
ReDim Preserve MenuControls(MenuItems)
For i = 0 To MenuItems
For cycleitems = 0 To UBound(MenuControls)
If Control = MenuControls(i) Then
'control is already listed
ExistingControl = True
Exit Sub
End If
Next cycleitems
Next i
If ExistingControl = False Then
ReDim Preserve MenuControls(MenuItems)
MenuControls(MenuItems) = Control
MenuItems = MenuItems + 1
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.