vb 怎么写鼠标移动事件
现有一个image控件,当鼠标移到该控件时,变换另一图像,鼠标移开,又变回原图像,求代码第一个回答太简单,第二个回答经测试,移进去可以,移出去后不能还原原图像...
现有一个image控件,当鼠标移到该控件时,变换另一图像,鼠标移开,又变回原图像,求代码
第一个回答太简单,第二个回答经测试,移进去可以,移出去后不能还原原图像 展开
第一个回答太简单,第二个回答经测试,移进去可以,移出去后不能还原原图像 展开
3个回答
展开全部
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
4) 在Command1的MouseMove事件中编写以下代码:
Private Sub image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean '鼠标进入的标志位
MouseEnter = (0 <= X) And (X <= image1.Width) And (0 <= Y) And (Y <=
Command1.Height) '计算鼠标的移动是否在image1里面
If MouseEnter Then '鼠标已经进入
set image1.picture = loadpicture("c:\2.bmp")
Me.Caption = "Mouse In Button!"
SetCapture image1.hWnd
Else '鼠标已经离开
set image1.picture = loadpicture("c:\1.bmp")
Me.Caption = "Mouse Out!"
ReleaseCapture
End If
End Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
4) 在Command1的MouseMove事件中编写以下代码:
Private Sub image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean '鼠标进入的标志位
MouseEnter = (0 <= X) And (X <= image1.Width) And (0 <= Y) And (Y <=
Command1.Height) '计算鼠标的移动是否在image1里面
If MouseEnter Then '鼠标已经进入
set image1.picture = loadpicture("c:\2.bmp")
Me.Caption = "Mouse In Button!"
SetCapture image1.hWnd
Else '鼠标已经离开
set image1.picture = loadpicture("c:\1.bmp")
Me.Caption = "Mouse Out!"
ReleaseCapture
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'鼠标在image上移动
image1.picture = loadpicture("c:\2.bmp")
End Sub
Private Sub form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
’鼠标离开image,在窗体上移动
image1.picture = loadpicture("c:\1.bmp")
End Sub
'鼠标在image上移动
image1.picture = loadpicture("c:\2.bmp")
End Sub
Private Sub form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
’鼠标离开image,在窗体上移动
image1.picture = loadpicture("c:\1.bmp")
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询