|
-
Oct 28th, 2005, 05:51 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Buttons Problem...
Hello,
if i make a picture box and put a picture in it and use it as a button its okay i m having o problem in this, but is it possible if mouse come over button ( havn't clicked yet ) it changes image .......
i hope u undertsnad what im saying about
-
Oct 28th, 2005, 05:52 AM
#2
Re: Buttons Problem...
In the mousemove event, simply load a different image into it.
-
Oct 28th, 2005, 05:53 AM
#3
Fanatic Member
Re: Buttons Problem...
what he means is this:
VB Code:
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Image1.Picture = LoadPicture('your picture)
End Sub
-
Oct 28th, 2005, 05:57 AM
#4
Re: Buttons Problem...
Correct (thanks paralinx...I probably should have posted a code example ) and when the mouse leaves the picture/image control, revert it back to its original.
Bear in mind that these images would need to be deployed with your application so make sure you include them in your setup package.
-
Oct 28th, 2005, 05:59 AM
#5
Fanatic Member
Re: Buttons Problem...
It's all good I was going to post the code anyway but you posted before I did. What you can do for when the mouse leaves the image to put it back to the normal image or no image is this in the form:
VB Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Image1.Picture = 'Starting Picture or No Picture
End Sub
-
Oct 28th, 2005, 06:27 AM
#6
Thread Starter
Addicted Member
Re: Buttons Problem...
hello, i successfully did that but i still have problem.....
when mouse go over it changes picture but when mouse go from over that picture that picture doesn't come back to old one
-
Oct 28th, 2005, 06:38 AM
#7
Re: Buttons Problem...
 Originally Posted by mfurqan
hello, i successfully did that but i still have problem.....
when mouse go over it changes picture but when mouse go from over that picture that picture doesn't come back to old one
API to the rescue.
VB Code:
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetCapture Lib "user32" () As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X < 0) Or (Y < 0) Or (X > Picture1.Width) Or (Y > Picture1.Height) Then
ReleaseCapture ' mouse is no long over picture control, so change it back to original
Picture1.Picture = LoadPicture("c:\Original.jpg")
ElseIf GetCapture() <> Picture1.hwnd Then
SetCapture Picture1.hwnd 'mouse is over the picture box so change the picture to new guy
Picture1.Picture = LoadPicture("c:\NewPicture.jpg")
End If
End Sub
Note: This will NOT work with an Image control. You MUST use a Picture control with this code as it requires the use of the control's hWnd property. Image controls do not have an hWnd property.
Last edited by Hack; Oct 28th, 2005 at 07:24 AM.
-
Oct 28th, 2005, 07:19 AM
#8
Thread Starter
Addicted Member
Re: Buttons Problem...
yeh it worked thanks
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
|