RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
Hey there, so I have a series of labels which I've identified as "Well" in the tag property. The idea is to highlight upon mouse hover to vbGreen just to add a level of user-interaction. I have it completely working (code below) based on a class module approach but if I hold the mouse over any of the label, there is intermittent flickering of all the other labels. Even if I just hold the mouse icon over the label and not move, the flickering is really noticeable and distracting. The highlighting feature is great but not at the expensive of all this flickering. What can I do here?
Class Module
I'll forgo the code that sets up the class module, nothing wrong with that. Below is the code called by the class module
Userform Code
Class Module
VBA Code:
Option Explicit
Public WithEvents WellAnalysisGroup As MSForms.Label
Private mfrmParent As Object
'--public properties
Public Property Set Parent(frmParent As Object)
Set mfrmParent = frmParent
End Property
'--event procedures
Private Sub WellAnalysisGroup_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
'This clears resets all the color
Call WellAnalysisGroup.Parent.ResetColor
'After everything is cleared, this changes the color
WellAnalysisGroup.BackColor = vbGreen
End Sub
I'll forgo the code that sets up the class module, nothing wrong with that. Below is the code called by the class module
Userform Code
VBA Code:
Public Sub ResetColor()
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeName(ctrl) = "Label" Then
If ctrl.Tag = "Well" Then
ctrl.BackColor = vbWhite
End If
End If
Next ctrl
End Sub