'commandbutton的Style设为1 (只能在设计时修改) Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) With Command1 SetCapture .hWnd If X > 0 And X < .Width And Y > 0 And Y < .Height Then .BackColor = vbRed Else SetCapture 0 .BackColor = vbBlue End If End With End Sub
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As LongPrivate Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command1
SetCapture .hWnd
If X > 0 And X < .Width And Y > 0 And Y < .Height Then
.BackColor = vbRed
Else
SetCapture 0
.BackColor = vbBlue
End If
End With
End Sub
可以在MOUSE_MOVE事件中写代码
加载图片使用LOADPICTURE函数