Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = IMAGE3.Picture
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = IMAGE2.Picture
End Sub
2.也可以用API函数与时钟判断.. 相关API声明和函数.具体程序你自己写吧.
Public Type SmPointAPI
X As Long
Y As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
'
'取当前鼠标的屏幕坐标值.
'函数:SmScrMouseXY
'参数:
'返回值:SmPointAPI结构体.
'例子:
Public Function SmScrMouseXY() As SmPointAPI
Dim hCursorWnd As Long, Point As SmPointAPI
Dim M_Scrxy As SmPointAPI
GetCursorPos Point
hCursorWnd = WindowFromPoint(Point.X, Point.Y)
M_Scrxy.X = Point.X * 15: M_Scrxy.Y = Point.Y * 15
End Function
这是用picturebox实现的:
'一个picturebox,一个imagelist控件(事先加载两张不同的图片)
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X >= 0) And (Y >= 0) And (X < Picture1.Width) And (Y < Picture1.Height) Then
SetCapture Picture1.hwnd
Set Picture1.Picture = ImageList1.ListImages(1).Picture
Else
Set Picture1.Picture = ImageList1.ListImages(2).Picture
ReleaseCapture
End If
End Sub