Clearing MouseMove Event of a label

aommaster

New Member
Joined
Mar 13, 2004
Messages
23
Hello

I have a userform that is dynamically generating labels. The reason for this is because I have a few thousand labels to generate. I am also attaching a MouseMove event to each dynamically generated label using a its own class.

The class contains this code:
Code:
Private Sub m_objlb_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    m_objlb.Caption = "x"
End Sub
What this will do is whenever the mouse hovers over a label, its caption is changed to an "x".

Now, I would like to reset the caption once the mouse is no longer on the label. How do I go about doing this? Mind you: I don't think looping through all labels and resetting them is feasible because of the sheer number of labels involved.

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

jsotola

Well-known Member
Joined
Nov 15, 2013
Messages
524
this is just an idea

put another larger, transparent label under your labels

either one large one, or a bunch of smaller ones

when the mouse pointer exits one of your labels, it enters the transparent label

add code to your existing MouseMove code
the code would store the current label ID in a global variable (lastLabel = Me.Name) (not tested)


when the pointer enters the transparent label, it calls the transparent label MouseMove code,
which retrieves the ID of the label from the global variable and updates the associated label

you could also use the X Y values in the MouseMove handler to calculate which label you just exited
 

Watch MrExcel Video

Forum statistics

Threads
1,130,046
Messages
5,639,758
Members
417,109
Latest member
996

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