|
-
May 29th, 2001, 07:00 PM
#1
Thread Starter
Hyperactive Member
rollover image...please helppp!!!!
hello,
how do i make an image change to another image on top of it when the mouse moves over it???
thanks in advance
Visual Basic 6, HTML, JavaScript, learning C++
-
May 29th, 2001, 07:07 PM
#2
-
May 29th, 2001, 07:09 PM
#3
Junior Member
You can use the imageList control to store your various images.
When firing the mouseover event , just change the .picture property of you image/picture control
THeNU
-
May 29th, 2001, 07:10 PM
#4
Frenzied Member
Test to see if the cursor is over the image and when it is out.
Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1 = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\Assorted\beany.bmp")
End Sub
-
May 29th, 2001, 07:16 PM
#5
-
May 29th, 2001, 07:22 PM
#6
Need-a-life Member
Here it is
Hope this helps:
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. You can also get it from an imagelist or load it directly from the hard disk (with the loadpicture)
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
May 29th, 2001, 07:29 PM
#7
Junior Member
Mc Brain
What you can do is to detect when the mouse leave the image/picture control, by i.e. checking the mouseover event of the surrounding controls (probably just the form or a frame).
picture.mouseover
change picture to #1
form.mouseover
change picture back to #0
thenu
-
May 29th, 2001, 07:32 PM
#8
Hyperactive Member
For detecting when the mouse is out of the picture box, allocate it in a frame and then use the mouse-over event of the frame to restore the original image.
Combat poverty: kill a poor!!
-
May 29th, 2001, 07:32 PM
#9
Frenzied Member
Mc Brain. In my post i explain that you have to check to see if the cursor is in the picturebox or out. I guess that i could have written the entire code. That would have been too easy.
-
May 29th, 2001, 07:41 PM
#10
Need-a-life Member
For detecting when the mouse is out of the picture box, allocate it in a frame and then use the mouse-over event of the frame to restore the original image.
I don't like this solution since it would only work when you try your program. I can assure you, that the final user won't move the mouse slowly so that the image is loaded back. Not because they're evil, just because they are not suppose to know that the image will change back when the move the mouse over the frame. I guess that mine is the best solution for this stuff.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Jul 29th, 2002, 10:18 AM
#11
I agree with McBrain. SetCapture and ReleaseCapture is the way to go.
However you need to make a call to SetCapture in the MouseUp event of the PictureBox also otherwise it wont work proparly if you click on the PictureBox.
Cheers,
-
Jul 29th, 2002, 02:00 PM
#12
Need-a-life Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|