MouseOver Highlighting of Label - Userform Flickering Problem

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
377
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
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
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
L

Legacy 456155

Guest
Maybe you should not set the property unless you must. Try
If ctrl.BackColor <> vbWhite Then ctrl.BackColor = vbWhite
 

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
377
From the province of Newfoundland and Labrador in eastern Canada. Labrador is known as the big land here - but I guess there's a few places around the world that could qualify including Wyoming (never been).
 
L

Legacy 456155

Guest
There is a city in Wyoming name Rawlins and you mentioned big land. That's why I asked. Compared to where I live, Wyoming is ginormous. Greetings neighbor! I'm currently from Indiana. Have a great Sunday!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,329
Messages
5,836,675
Members
430,444
Latest member
WrenchBoy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top