2个回答
展开全部
这个问题我可以帮你解决。请速联系我。
追问
说说看,怎么解决?请写源码。
追答
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private Sub Form_Load()
ShowCursor 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
ShowCursor 1
End Sub
主人为什么不给我悬赏分呢。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是屏蔽在这个窗口内的左键,还是屏蔽系统中的?
追问
是窗口内的左键
追答
楼上的,那个是把鼠标隐藏了。。不能实现楼主的要求。
以下代码可以完美实现要求,还可以屏蔽其它键:
首先,建一个模块,把下面代码放里边:
Option Explicit
Private Const HC_ACTION = 0
Private Const HC_NOREMOVE = 3
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Public hHook As Long
Public Function MouseProc(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If ncode = HC_ACTION Then
If (wParam = WM_LBUTTONDOWN) Or (wParam = WM_LBUTTONDBLCLK) Then ’把这里的LBUTTON改为RBUTTON,则可以屏蔽右键。或者同样的加上两个Or的条件,可以屏蔽左右键。
MouseProc = 1
Exit Function
End If
End If
MouseProc = CallNextHookEx(hHook, ncode, wParam, ByVal lParam)
End Function
然后,把下面代码放窗体代码里:
Option Explicit
Private Const WH_MOUSE = 7
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Sub Form_Load()
hHook = SetWindowsHookEx(WH_MOUSE, AddressOf MouseProc, 0, App.ThreadID)
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnhookWindowsHookEx hHook
End Sub
即可实现楼主的要求
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询