vb显示鼠标位置

前端之家收集整理的这篇文章主要介绍了vb显示鼠标位置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Private Sub Form1_MouseMove(ByValeventSender As System.Object,ByVal eventArgs AsSystem.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Dim Button As Short = eventArgs.Button\ &H100000
Dim Shift As Short =System.Windows.Forms.Control.ModifierKeys \ &H10000
Dim X As Single = eventArgs.X
Dim Y As Single = eventArgs.Y
'当鼠标移动时,相应的状态栏也应该改变
'判断工具栏的按钮是否按下,如果是,则显示鼠标位置
If Toolbar1.Buttons(1).Value =MSComctlLib.ValueConstants.tbrPressed Then
StatusBar1.Panels(1).Text ="当前鼠标位置:" & X & ","& Y
'否则,显示
Else
StatusBar1.Panels(1).Text =""
End If
End Sub
Private Sub Toolbar1_ButtonClick(ByValeventSender As System.Object,ByVal eventArgs AsAxMSComctlLib.IToolbarEvents_ButtonClickEvent) Handles Toolbar1.ButtonClick
'当单击工具栏时,立刻改变状态栏的信息;要不会出现单击按钮后不发生任何改变
Select Case eventArgs.Button.Key
Case "ShowMousePos"
If Toolbar1.Buttons(1).Value =MSComctlLib.ValueConstants.tbrPressed Then
StatusBar1.Panels(1).Text= "当前鼠标位置:0,0"
Else
StatusBar1.Panels(1).Text= ""
End If
Case Else
End Select
End Sub


来自 @L_404_0@

原文链接:https://www.f2er.com/vb/259217.html

猜你在找的VB相关文章