【发布时间】:2015-02-01 17:52:03
【问题描述】:
我正在使用以下代码根据光标位置更改光标图像。我注意到,如果光标穿过标签或文本框或其他东西,光标将不会改变,直到它进入我的表格布局的一部分,这可能会改变中间页面。
Private Sub TableLayoutPanel1_MouseMove(sender As Object, e As MouseEventArgs) Handles TableLayoutPanel1.MouseMove
If e.Location.X > Me.Width - 7 And e.Location.Y > 12 And e.Location.Y < Me.Height - 12 Then
Me.Cursor = Cursors.SizeWE
ElseIf e.Location.X < 6 And e.Location.Y > 12 And e.Location.Y < Me.Height - 12 Then
Me.Cursor = Cursors.SizeWE
ElseIf e.Location.Y > Me.Width - 12 And e.Location.X > 12 And e.Location.X < Me.Width - 12 Then
Me.Cursor = Cursors.SizeNS
ElseIf e.Location.Y < 6 And e.Location.X > 12 And e.Location.X < Me.Width - 12 Then
Me.Cursor = Cursors.SizeNS
Else
Me.Cursor = Cursors.Default
End If
End Sub
我想知道的是,是否有一个不同的 mousemove 事件只关注光标位置而不是它的移动。我试过form mousemove,但没用。
希望这是有道理的。
【问题讨论】:
-
这是完全正常的,那些其他控件会获取 MouseMove 事件。您必须将 Capture 属性设置为 True 以避免发生这种情况。不是真正有用的东西,这不是需要解决的问题。