VB里的mousemove事件举例

2024-12-18 22:17:56
推荐回答(5个)
回答1:

这是鼠标移动时发生的事件,如:

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

MsgBox "你点到我啦!"

End Sub

当鼠标移动到这个标签控件的时候,就弹出对话框

扩展资料:

鼠标事件是Visual Basic编程中最常用到的事件,多数控件都支持鼠标操作,因此对鼠 标事件进行编程是非常重要的。

鼠标事件主要有以下几种:

MouseDown:鼠标按下时发生的事件。

MouseUp:鼠标抬起时发生的事件。

MouseMove:鼠标移动时发生的事件,对某控件的此事件进行编程,则当鼠标移过此控件时就会触发此事件,执行其相应代码。

参考资料来源:百度百科-VB事件

回答2:

mousemove事件就是鼠标在对象上移动
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Cls
Print "鼠标在按钮上移动" & Now
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Cls
Print "鼠标在窗体移动" & Now
End Sub

回答3:

放上一个picture控件,然后
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PSet (X, Y), &HFF&‘x,y是当前鼠标所在点的坐标,&HFF&是颜色
End Sub
鼠标在picture控件上移动时会画出一条红线
若要鼠标按住左键后才画出红线,可以加个判断
If Button <> 1 Then Exit Sub

回答4:

这是鼠标移动时发生的事件,如:
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox "你点到我啦!"
End Sub
当鼠标移动到这个标签控件的时候,就弹出对话框

回答5:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Cls
Circle (X, Y), Rnd * 1000, RGB(255 * Rnd, 255 * Rnd, 255 * Rnd)
End Sub

圆形相随——鼠标移动,光环跟进!