hello,
what is the code to make a rollover image effect? I have a picture and when the mouse moves over it, I want the image to change into a different image. I asked this before, but the code did not make sense.
Printable View
hello,
what is the code to make a rollover image effect? I have a picture and when the mouse moves over it, I want the image to change into a different image. I asked this before, but the code did not make sense.
What is it exactly what you're needing. I've post you a code that does the "rollover image" effect. What of all that did not make sense?Do you need something special effect?
A simple way to do it:
have 3 ImageControls
1 main
2 that are not visible
on mousemove
Image1.picture = Image2.picture
then to set it back....image1.picture = image3.picture
This is the best way I know to create a "rollover image" effect. The "how" you load the new image is up to you, there are several different way to do it: Loadpicture, a picture array, an ImageList, whatever. But the essence of the effect is shown in this code:
Code:Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Picture1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
.Picture = RollOver(0).Picture
Else
SetCapture .hwnd
.Picture = RollOver(1).Picture
End If
End With
End Sub
The PictureBox RollOver is an array, but you can use whateve method you like to load one or other image.
good Idea ReleaseCapture / SetCapture....
then you wont have to program the form mousemove to set the image back
much cleaner Display
:D
I would Like my images to swap when the cursor is moved over one image.