Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a label display a shadow simply when the mouse is over it
Keywordslabel, shadow, mouse
CategoriesGraphics, 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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated