If I'm right then you really need to use some API calls.
However, here's the cheap way of doing it.
Make Image2 cover your entire form and send it behind all the other controls.
Image 1 is the control that you are animating when the mouse goes over it.
This is the cheap method because if you hover the mouse over Image1 then move it off your form really fast the _MouseMove event for Image2 may not get fired.
VB Code:
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.BorderStyle = 1
End Sub
Private Sub Image2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.BorderStyle = 0
End Sub
This world is not my home. I'm just passing through.
Check out the MCL Region button download (with source) from Merrion Computing
This allows you to have a button with different images defined for up/down/disabled and hover states and handles the clipping and painting of this automatically....
darre1's suggestion before last is an improvement on what I was suggesting earlier, but still suffers from the same problem. If your control is close to the edge of the form and you move your mouse off really quickly then the Form_MouseMove event doesn't fire.
This world is not my home. I'm just passing through.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Imgclose.Picture <> 0 Then Imgclose.Picture = LoadPicture()
End Sub
Private Sub Imgclose_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Imgclose.Picture = LoadPicture("C:\Windows\desktop\riskfree\images\minimize.jpg")
End Sub
the first picture dont show up only when i mouse over image works.
'Move form code part1 :
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub ReleaseCapture Lib "User32" ()
' End move form code part1 :
Option Explicit
Private Sub Form_Load()
Images(0).Picture = LoadPicture(App.Path & "\image0.jpg")
Images(2).Picture = LoadPicture(App.Path & "\image1.jpg")
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Images(0).Visible = True
Images(2).Visible = False
End Sub
Private Sub Images_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Index = 0 Then
Images(0).Visible = False
Images(2).Visible = True
End If
End
End Sub
'Move form code part2 :
Private Sub Imgtop_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2
If Button = 1 Then
ReleaseCapture
SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
'End move form code part2 :
/vbcode
And i have included a zip of the program so you can see what i mean move the mouse over the close button.