|
|
Title | Make a label display a shadow simply when the mouse is over it |
Keywords | label, shadow, mouse |
Categories | Graphics, Controls, Tips and Tricks |
|
|
Make a Label for the shadow with BackStyle set to Transparent. Copy and paste the Label and change the color for the text. Position the text label slightly offset from the shadow label's position. Set the shadow Label's Visible property to False.
In the text Label's MouseMove event handler, make the shadow Label visible if it is not already.
In the form's MouseMove event handler, hide the shadow Label if it is visible.
|
|
Private Sub lblText_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If Not lblShadow.Visible Then lblShadow.Visible = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As _
Integer, X As Single, Y As Single)
If lblShadow.Visible Then lblShadow.Visible = False
End Sub
|
|
One problem with this method is the form's MouseMove event handler is not guaranteed to fire. If you move the mouse very quickly from the label off the form, no Form_MouseMove event may fire so the shadow will remain visible. For a way to fix this problem, see Make a label display a shadow when the mouse is over it.
|
|
|
|
|
|