-
I want to have a label that when a user places there mouse over it, it will magicaly reveal an image. I have the image already set to Visible = False, now all I need is to code the Mouse over event. Only problem is that I have no idea how to code it. Any ideas, URL's to glance at, or examples would be greatly appreciated.
Thank you for your time and efforts,
Daniel Christie
-
The easy way
This is the easy way, but it isn't as reliable as using API calls to capture the cursor position.
Simply write code in the MouseMove event of the label to set the visible property of the image to TRUE.
In the MouseMove event of the form, set the visible property of the image to FALSE again.
The problem with this is that sometimes the user can move the mouse away from the label quickly enough that the form's MouseMove event doesn't fire (this is especially true if your label is near the edge of your form). You also should add code to any nearby controls' MouseMove events to hide the image, in case the user moves from your label to another control without going over the form.
Sample project:
- Drop a label and an image on a form (keep default names)
- Set the image's picture property to a picture of your choice
- Paste the following code into the form's code window
- Run the project and move the mouse over the label
Code:
Option Explicit
Private Sub Form_Load()
Image1.Visible = False
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Visible = False
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Visible = True
End Sub
[Edited by seaweed on 03-28-2000 at 10:08 PM]