'Command1 style设为1Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If X > 0 And X < Command1.Width And Y > 0 And Y < Command1.Height Then Command1.Picture = LoadPicture(App.Path & "\1.jpg") SetCapture Command1.hWnd Else Command1.Picture = LoadPicture(App.Path & "\3.jpg") ReleaseCapture End If End Sub
Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If X > 0 And X < Command1.Width And Y > 0 And Y < Command1.Height Then Command1.Caption = "进入" SetCapture Command1.hWnd Else Command1.Caption = "离开" ReleaseCapture End If End Sub
用viena(维也纳nn-实心木头人) ( ) 的方法 另外写: Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Command1.Picture = LoadPicture("C:\2.ico") End Sub
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 0 And X < Command1.Width And Y > 0 And Y < Command1.Height Then
Command1.Picture = LoadPicture(App.Path & "\1.jpg")
SetCapture Command1.hWnd
Else
Command1.Picture = LoadPicture(App.Path & "\3.jpg")
ReleaseCapture
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > 0 And X < Command1.Width And Y > 0 And Y < Command1.Height Then
Command1.Caption = "进入"
SetCapture Command1.hWnd
Else
Command1.Caption = "离开"
ReleaseCapture
End If
End Sub
另外写:
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.Picture = LoadPicture("C:\2.ico")
End Sub