programmatically format label

G

george

Hi to all,

I have a label which I use as a command button to open
another form through its click event. I would like each
time the mouse passes over it to change font color and
font size and as soon as the mouse moves away to return to
its previous state. Is this possible?

thanks in advance, george
 
M

MacDermott

In theory, yes -
in practice, it's a bit more problematic.
Your label has a MouseMove event you can capture and use to make the changes
you want.
Be sure to check whether you've already made the changes (a flag
variable is useful for this); otherwise you'll get a jerky effect as Access
re-applies your settings as the mouse moves along.

However, there is no "MouseLeave" event you can capture to turn your
settings off, so you're stuck defining a larger area around the label (e.g.
another label under it, somewhat larger, same color as the background), and
capturing its MouseMove event.
One problem there is that if the mouse is moved very rapidly, it may
miss the "off" area.
 
C

Chris Reveille

Yes. Here is an example. You use a label control. In the
label's MouseMove event, set its SpecialEffect property to
Raised, and in the MouseMove event of the surrounding form
section, set it back to Flat. Like this:

'----- start of example code -----
Private Sub lblMouseOver_MouseMove( _
Button As Integer, _
Shift As Integer, X As Single, _
Y As Single)

With Me.lblMouseOver
If .SpecialEffect = 0 Then .SpecialEffect = 1
End With

End Sub

Private Sub Detail_MouseMove( _

Button As Integer, _
Shift As Integer, X As Single, _
Y As Single)

With Me.lblMouseOver
If .SpecialEffect = 1 Then .SpecialEffect = 0
End With

End Sub

Chris
 
F

fredg

Hi to all,

I have a label which I use as a command button to open
another form through its click event. I would like each
time the mouse passes over it to change font color and
font size and as soon as the mouse moves away to return to
its previous state. Is this possible?

thanks in advance, george

You can use the label's MouseMove event.

If X > 0 And X < 1.25 * 1440 And Y > 0 And Y < 0.25 * 1440 Then
Me!LabelName.ForeColor = vbGreen
Me!LabelName.FontSize = 12
Else
Me!LabelName.ForeColor = vbBlue
Me!LabelName.FontSize = 10
End If

The above assumes a label size of 1.25 inches x 0.25 inches.
All measurements are in Twips, 1440 per inch.
You cannot 'swipe' over the label, but must move with a moderate
speed.
 

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

Top