因为鼠标移过按钮没有内置事件,所以只好用消息
应该是三张图片吧
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.DownPicture = LoadPicture(App.Path & "\按下.gif") '按下
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If 0 <= X And X <= Command1.Width And 0 <= Y And Y <= Command1.Height Then
SetCapture Command1.hwnd
Command1.Picture = LoadPicture(App.Path & "\移过.gif") '鼠标移动到按钮
Else
ReleaseCapture
'这里就是鼠标离开按钮
Command1.Picture = LoadPicture(App.Path & "\离开.gif")
End If
End Sub
Private Sub Form_Load()
Command1.Picture = LoadPicture(App.Path & "\离开.gif")
End Sub