笨辦法:
創新互聯公司是專業的鐵力網站建設公司,鐵力接單;提供成都網站設計、網站制作,網頁設計,網站設計,建網站,PHP網站建設等專業做網站服務;采用PHP框架,可快速的進行鐵力網站開發網頁制作和功能擴展;專業做搜索引擎喜愛的網站,專業的做網站團隊,希望更多企業前來合作!
加個菜單控件,設置個空選項
再把這個菜單選項的快捷鍵設置成ctrl+alt+del
.net的代碼真木有寫過。
VB 可以屏蔽 包括ctrl+alt+del在內的所有鍵盤按鍵消息
其實你只要后臺截獲按鍵的消息后,直接屏蔽掉就可以了。
VB代碼我有 net木有。
最簡單的就是把屬性改一下,效果跟無框的差不多。
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
Me.ControlBox = False
Me.MaximizeBox = False
Me.Text = ""
至于hook的問題,它確實是比系統慢了一步得到消息,當前線程或全局的都一樣,不過你可以先攔截Windows鍵或者Up鍵其中一鍵來阻攔組合鍵。
只是文本框的話:
Private Const charSet As String = "abcdefghijklmnopqrstuvwxyz"
Private Sub textbox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textbox1.KeyPress
If charSet.IndexOf(e.KeyChar) = -1 And e.KeyChar "" Then
e.Handled = True
End If
End Sub
這樣只能輸入charset 規定的字符
'點擊窗體隱藏,按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
網頁標題:vb.net屏蔽組合鍵,vb中關閉程序窗口的組合鍵
當前網址:http://vcdvsql.cn/article40/hsopho.html
成都網站建設公司_創新互聯,為您提供網站建設、Google、建站公司、App設計、品牌網站建設、ChatGPT
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯