Mouse Over Effect Help

F

fredg

How do I have a label font go too bold when a user moves the mouse over the
label?

You cannot use a label bound to a text control. If that is what you
have, first cut the label, then paste it back onto the section it is
in. Move it where you want it.

Or add a new label control from the tool box.

Then, code the label's MouseMove event:

If X > 0 And X <= 750 And Y > 0 And Y <= 300 Then
Me.LabelName.FontBold = True
Else
Me.LabelName.FontBold = False
End If

Change the measurements according to the Width (X) and Height (Y) of
the control (in Twips, 1440 per inch).
 
G

Guest

Excellent. Thank you

Klatuu said:
In design view, select the control you want to do this in.
Click on Properties.
Select the Events tab
Select the Move Move event
Click the button on the right with the 3 dots ...
Select code builder
Enter this:

Me.MyControlName.FontBold = True

change myControlName to the name of your control

Do the same thing for the rectangle control to make it normal:
Me.MyControlName.FontBold = False
 
G

Guest

Lables have no events, so you will have to find another way. One would be to
make it into a text box and use the Mouse Move event. Of course, you will
have to set the text box's properties so it acts like a label, for example,
you will want to set the Tab Stop property to No and the Locked property to
Yes, and Special Effects to Flat. You still have the problem that once you
have moved the mouse over the control and the font goes bold of getting it
back to normal. The mouse move event fires when the mouse moves over the
control, but not when it leaves.

A way to handle that is to put a rectangle control around the text box and
make it invisible by setting its properties so it wont be seen, then use it's
mouse move event to turn the font back to normal. You wont notice anything
as you move across it to the text box, because the text is already normal.
After the text box makes it bold and you move away, it will move over the
rectangle and turn it back to normal.
The effect then will be that as your mouse cursor moves over the text box,
the font will go bold and when you move away, it will go normal.
 
G

Guest

In design view, select the control you want to do this in.
Click on Properties.
Select the Events tab
Select the Move Move event
Click the button on the right with the 3 dots ...
Select code builder
Enter this:

Me.MyControlName.FontBold = True

change myControlName to the name of your control

Do the same thing for the rectangle control to make it normal:
Me.MyControlName.FontBold = False
 
G

Guest

What code do I use on a command button to go bold on move over and then
return to normal?
 
D

Duane Hookom

This code kinda works if you don't move your mouse real quickly. A more
robust solution would use more generic code and probably turn off the bold
when the mouse is moved over the form.

Private Sub lblMyLabel_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim intEdge As Integer
Dim intWidth As Integer
Dim intHeight As Integer
intEdge = 30 'buffer zone to turn off bold
intWidth = Me.lblMyLabel.Width
intHeight = Me.lblMyLabel.Height
If X > intEdge And X < (intWidth - intEdge) _
And Y > intEdge And Y < (intHeight - intEdge) _
And Me.lblMyLabel.FontBold <> True Then
Me.lblMyLabel.FontBold = True
Else
Me.lblMyLabel.FontBold = False
End If
End Sub
 
G

Guest

It works, but not like I wanted. I goes bold but sometimes it does not go to
normal font again unless I move the mouse over it very slow which is not what
I am looking for. I appreciate the help!
 
M

Marshall Barton

You're right that **attached** labels don't have events,
BUT, as Fred said, stand alone labels do have the MouseMove
event. Thus, you can avoid all those complications.

Instead of adding a large, extra rectangle control, you can
use the form section's MouseMove event to set the label's
font back to normal.
 
T

TC

*Now* I see what you intended with the buffer zone! (It took me a few
tries to see it. Initially, I thought that you were trying to detect
the case were the cursor was nearly, but not quite, over the label.)

But it just won't work reliably, unless the user moves the cursor very
slowly. He definitely needs to reverse the effect, in the form and
section level events. That's the only way that it will work reliably.
He might even need to do it (as well) in the events of the adjacent
controls!

So I'd remove the buffer zone, it really doesn't serve a sound purpose.

Cheers :)
TC (MVP Access)
http://tc2.atspace.com
 
T

TC

K, try this:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lblMyLabel.FontBold = False
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Me.lblMyLabel.FontBold = False
End Sub

Private Sub lblMyLabel_MouseMove(Button As Integer, Shift As Integer, X
As
Single, Y As Single)
Me.lblMyLabel.FontBold = True
End Sub

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
D

Dirk Goldgar

Klatuu said:
Lables have no events, so you will have to find another way.

*Attached* labels have no events, because they participate in the events
of the control they're attached to. Unattached labels have events:
Click, DblClick, MouseMove, MouseDown, and MouseUp. So the label
doesn't have to be transformed into a text box; one just has to make
sure it's not attached to any other control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top