如何在VB.net中禁用用户的鼠标和键盘(使鼠标不可见)?

问题描述:

在Visual Basic中,如何让用户的光标不可见并且键盘输入未“启用”?如何在VB.net中禁用用户的鼠标和键盘(使鼠标不可见)?

+0

在这里检查,http://*.com/questions/2828925/vb-net-disable-the-keyboard-and-mouse – paragy 2011-05-24 20:50:46

请尝试下面的代码。添加这些API声明您declations部分:

Private Declare Function BlockInput Lib "user32" Alias "BlockInput" (ByVal fBlock As Integer) As Integer 
Private Declare Function ShowCursor Lib "user32" (ByVal lShow As Long) As Long 

在你的方法,添加以下代码:

BlockInput 1 
ShowCursor 0 

要重新启用键盘和鼠标,请尝试以下操作:

BlockInput 0 
ShowCursor 1 
+0

如果你正在使用网格控制像超网格。您可以在Ultrgrid e.SuppressKeyPress = True的keydown事件中使用以下代码 – Uttam 2017-09-26 07:29:34