vb中怎么实现屏蔽Alt+Tap的组合键!

这个怎么实现啊?... 这个怎么实现啊? 展开
 我来答
良水毅魔滴奋p
2010-04-24 · TA获得超过115个赞
知道答主
回答量:61
采纳率:0%
帮助的人:0
展开全部
'点击窗体隐藏,按Alt + Tab回调窗体

Option Explicit
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString _
As String) As Integer
'为全局热键添加一个标识符
Private Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long, _
ByVal fsModifiers As Long, ByVal vk As Long) As Long
'hWnd:接收热键产生WM_HOTKEY消息的窗口句柄
'id:定义热键的标识符,GlobalAddAtom函数获得热键的标识符.
'MOD_ALT为Alt键,MOD_CONTROL为Ctrl键,MOD_SHIFT为Shift键,MOD_WIN为Windows按键。
'vk:定义热键的虚拟键码。
Private Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long _
) As Long

Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal _
hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal _
wRemoveMsg As Long) As Long
Private Declare Function WaitMessage Lib "user32" () As Long
Private Type POINTAPI
x As Long
y As Long
End Type

Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type

Const MOD_ALT = &H1
Const PM_REMOVE = &H1
Const WM_HOTKEY = &H312

Dim HotKey_ID As Long
Private HotKey_Flg As Boolean
Dim Message As Msg

Private Sub Form_Click()
Me.Hide
HotKey_ID = GlobalAddAtom("Alt + Tab")
'RegisterHotKey Me.hWnd, &HBFFF&, MOD_CONTROL + MOD_ALT, vbKeyG '注册 Ctrl+Alt+ G 为热键
RegisterHotKey Me.hWnd, HotKey_ID, MOD_ALT, 9 '注册 Ctrl+Alt+ G 为热键
Me.Hide
HotKey_Flg = False
Do While Not HotKey_Flg
WaitMessage '等待消息
If PeekMessage(Message, Me.hWnd, WM_HOTKEY, WM_HOTKEY, PM_REMOVE) Then '检查是否热键被按下
''''可以在此写入你要阻止的代码
Me.Show
End If
DoEvents '转让控制权,允许操作系统处理其他事件
Loop
End Sub

Private Sub Form_Unload(Cancel As Integer) '撤销热键的注册
HotKey_Flg = True
Call UnregisterHotKey(Me.hWnd, HotKey_ID)
End Sub
小李无刀
2010-04-24 · TA获得超过6359个赞
知道大有可为答主
回答量:8829
采纳率:78%
帮助的人:5031万
展开全部
这个是系统的热键,你要用HOOK钩子才行,比较有难度
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式