笨辦法:
創(chuàng)新互聯(lián)公司是專業(yè)的鐵力網(wǎng)站建設(shè)公司,鐵力接單;提供成都網(wǎng)站設(shè)計、網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行鐵力網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!
加個菜單控件,設(shè)置個空選項
再把這個菜單選項的快捷鍵設(shè)置成ctrl+alt+del
.net的代碼真木有寫過。
VB 可以屏蔽 包括ctrl+alt+del在內(nèi)的所有鍵盤按鍵消息
其實你只要后臺截獲按鍵的消息后,直接屏蔽掉就可以了。
VB代碼我有 net木有。
最簡單的就是把屬性改一下,效果跟無框的差不多。
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
Me.ControlBox = False
Me.MaximizeBox = False
Me.Text = ""
至于hook的問題,它確實是比系統(tǒng)慢了一步得到消息,當(dāng)前線程或全局的都一樣,不過你可以先攔截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 規(guī)定的字符
'點擊窗體隱藏,按Alt
+
Tab回調(diào)窗體
Option
Explicit
Private
Declare
Function
GlobalAddAtom
Lib
"kernel32"
Alias
"GlobalAddAtomA"
(ByVal
lpString
_
As
String)
As
Integer
'為全局熱鍵添加一個標(biāo)識符
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:接收熱鍵產(chǎn)生WM_HOTKEY消息的窗口句柄
'id:定義熱鍵的標(biāo)識符,GlobalAddAtom函數(shù)獲得熱鍵的標(biāo)識符.
'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
'轉(zhuǎn)讓控制權(quán),允許操作系統(tǒng)處理其他事件
Loop
End
Sub
Private
Sub
Form_Unload(Cancel
As
Integer)
'撤銷熱鍵的注冊
HotKey_Flg
=
True
Call
UnregisterHotKey(Me.hWnd,
HotKey_ID)
End
Sub
網(wǎng)頁標(biāo)題:vb.net屏蔽組合鍵,vb中關(guān)閉程序窗口的組合鍵
當(dāng)前網(wǎng)址:http://jinyejixie.com/article40/hsopho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、Google、建站公司、App設(shè)計、品牌網(wǎng)站建設(shè)、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)