1 Attachment(s)
Re-paint, mouseover and move !
Okay, here is my problem as it stands. This has been 'bugging' me for ages. ;) I would appreciate any help.
Basically, I have a form in the attached project, this form has a button image on it. When the mouse is moved over this image the image lights up (changes image), when the user moves the cursor off the image, it goes back to normal. However, I am having quite a few problems with it as follows and would like it if someone could help me to: - Stop the Re-painting of the entire form every time as it really looks un-professional
- Help to try and ensure that the image doesn't indent itself out of view as it currently does!
- And finally, perhaps improve upon my current code to make it more efficient.
If you could take a second to download the .zip file, it contains all appropriate project files and the images.
I really do need some help on this and would appreciate anyones efforts or input into how I can resolve these problems.
Thanks, and merry christmas :)
Jord
Re: Re-paint, mouseover and move !
You fogot to attach your project :O
Re: Re-paint, mouseover and move !
Sorry, I have edited the original post and it is now attached :rolleyes:
Re: Re-paint, mouseover and move !
You could use a graphical checkbox. It has a down image built in. Except for a border around the edge of the picture, it switches the images automatically with no flicker, and no offset. there is no mouseover, though.
Re: Re-paint, mouseover and move !
Hi intraman.
Take a good look at your modified project. You'll find two new Images on the form. It might not be the best way arround (resource file would probably be much cleaner), also VBisn't great to work with GIF type images so ordinary BMP perform much better (new images are included in the zip).
Buzz me if you have any questions.
Cheers. :wave:
Re: Re-paint, mouseover and move !
Wow, thanks.
Only problem now is that I don't understand the code so i couldnt implement it for other mouseovers very easily!
Re: Re-paint, mouseover and move !
Which part isn't clear? I had some comments in there ...
Anyway, the following is what I sent you and I think it's self-explanatory:
VB Code:
'general declaration section
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Const IDC_HAND = 32649&
Private Declare Function SetCursor Lib "user32" _
(ByVal hCursor As Long) As Long
Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, lpRect As RECT) As Long
Private Sub Picture4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'change mouse pointer to bring some attention from user
SetCursor LoadCursor(0, IDC_HAND)
End Sub
Private Sub filetime_Timer()
Dim Rec As RECT, Point As POINTAPI
' Get Left, Right, Top and Bottom of Picture4
GetWindowRect Picture4.hwnd, Rec
' Get current position of the cursor
GetCursorPos Point
'check if cursor if within control's boundaries
If Point.X >= Rec.Left And Point.X <= Rec.Right And _
Point.Y >= Rec.Top And Point.Y <= Rec.Bottom Then
'cursor is right above the control
Picture4.Picture = imgTemp(0).Picture
Else
'cursor is outside of control's boundaries
Picture4.Picture = imgTemp(1).Picture
End If
End Sub
Re: Re-paint, mouseover and move !
Okay, yeah - with your combined PM i now understand. Thanks.
Re: Re-paint, mouseover and move !