On mouse move event of label, change font color (1 Viewer)

aman

Registered User.
Local time
Yesterday, 19:07
Joined
Oct 16, 2008
Messages
1,250
Hi Guys

I am trying to write code that will change font color of the label on mouse move event of that label. It works fine but I also want to write code to change the color back to grey when mouse move event doesn't occur on that Label.

SO basically changing fontcolor to red on mouse move event of that label but otherwise when there is no mouse event on that label change is back to original color.

Code:
Private Sub lblDeclaration_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.lblDeclaration.ForeColor = vbRed
End Sub

Thanks
 

Minty

AWF VIP
Local time
Today, 03:07
Joined
Jul 26, 2013
Messages
10,366
You need to add a mousemove to the form background to change it back.

I would add a tag "Reset" on each label you want to do this to, then when the form background mousmove event fires simply loop through all the controls with that tag to reset them.

Then you don't need to hard code the reset for each label.
 

missinglinq

AWF VIP
Local time
Yesterday, 22:07
Joined
Jun 20, 2003
Messages
6,423
You need to add a mousemove to the form background to change it back.

Actually, I believe that would have to be the Section of the Form's background (i.e Header...Detail...Footer) as there is no Form Background.

Linq ;0)>
 

Minty

AWF VIP
Local time
Today, 03:07
Joined
Jul 26, 2013
Messages
10,366
Actually, I believe that would have to be the Section of the Form's background (i.e Header...Detail...Footer) as there is no Form Background.

Linq ;0)>
Yup of course - less haste more speed... :eek:
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 21:07
Joined
Feb 28, 2001
Messages
27,138
Just for "yocks" there is no intrinsic color constant for gray, so you have two alternatives.

A. In the form, define a color constant for yourself such as

Code:
MyGray = &H808080

This would give you about 50% gray. You can dink around with the numbers. For instance, 25% gray would be &H404040 and 75% gray would be &HC0C0C0

B. You could as an alternative create a LONG variable in the form's declaration area and when the form's Form_Load event fires, COPY the .BackColor of any one of the controls in question. Then when changing the control's color to its original state, you just copy the stored value.
 

Users who are viewing this thread

Top Bottom