vb.net隐藏鼠标 VB鼠标事件

vb.net 中按钮的显示问题

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

公司主营业务:成都做网站、网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出宿迁免费做网站回馈大家。

Static f As Boolean = False

If Not f Then

f = True

Button2.Hide()

Button3.Show()

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Static f As Boolean = False

If Not f Then

f = True

Button2.Show()

Button3.Hide()

End If

End Sub

vb.net中如何实现在 pictureBox内鼠标成大十字叉叉,横向和纵向都到达PictureBox的边界,各位帮帮忙。

这么难的问题才5分?给你思路:VB.NET改变鼠标形状的唯一方法就是加载图片,但是因为你要求“横向和纵向都到达PictureBox的边界”,也就是说,这个图片必须跟着鼠标移动而变化,显然这是无法做到的。

因此,可以先将鼠标指针隐藏,然后根据鼠标的当前位置,在PictureBox中画十字线,鼠标移动后,将前面画的线擦除,然后在新位置重新画。

为了不擦除PictureBox中已有的图像,在画十字线之前,先保存十字线所覆盖像素点的值,擦除的时候,恢复这些值就可以了。

VB.NET改变鼠标位置和让鼠标消失

几乎找不到真正VB.NET的api,都是自己将VB的api改成VB.NET的api,我的理解是声明中对应输入是H的地方保留Long,其他的Long改成Integer,既然VB.NET连MSDN都找不到较全的api说明,不保证api的用法在VB.NET其他版本中适用。

给你个好玩的例子,包括鼠标的隐藏(Ctrl_↓)、显示(Ctrl_↑),移动、点击

在Form1上放上2个TextBox,其中TextBox1.Multiline = True,并且面积大些,2个Button,运行后在TextBox1中点击一下会记录位置,移开鼠标,点击移动或点击Button,可模拟在TextBox1中的点击

Public Class Form1

Public My_MousePosition As Point

'模拟鼠标移动、点击

Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

'定义光标的位置

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer

'鼠标的隐藏

Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

TextBox1.Multiline = True

Button1.Text = "点击"

Button2.Text = "移动"

Me.KeyPreview = True

End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

If e.Control And e.KeyCode = Keys.Down Then ShowCursor(0)

If e.Control And e.KeyCode = Keys.Up Then ShowCursor(1)

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

TextBox2.Text = MousePosition.X " " MousePosition.Y

End Sub

Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick

My_MousePosition = MousePosition

TextBox1.Text = My_MousePosition.X " " My_MousePosition.Y vbCrLf

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

mouse_event(H2, 0, 0, 0, 0)

mouse_event(H4, 0, 0, 0, 0)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

End Sub

End Class

其中

mouse_event Lib "user32" (ByVal dwFlags As Long

的dwFlags的代码是

Const MOUSEEVENTF_LEFTDOWN = H2

Const MOUSEEVENTF_LEFTUP = H4

Const MOUSEEVENTF_MIDDLEDOWN = H20

Const MOUSEEVENTF_MIDDLEUP = H40

Const MOUSEEVENTF_MOVE = H1

Const MOUSEEVENTF_ABSOLUTE = H8000

Const MOUSEEVENTF_RIGHTDOWN = H8

Const MOUSEEVENTF_RIGHTUP = H10

vb.net屏蔽鼠标和键盘的问题

VB.net可以调用DLL吗?如果可以的话,你用VB6.0编写一个DLL给VB.NET调用就行了


标题名称:vb.net隐藏鼠标 VB鼠标事件
标题路径:http://abwzjs.com/article/doccecs.html