try this
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SETHOTKEY = &H32
Const HOTKEYF_SHIFT = &H1
Const HOTKEYF_CONTROL = &H2
Const HOTKEYF_ALT = &H4
Const HOTKEYF_EXT = &H8Private Type tInteger
aint As Integer
End Type
Private Type t2Byte
lByte As Byte
hByte As Byte
End Type
Private ii As tInteger
Private bb As t2BytePrivate Sub Command1_Click()
Dim wParam As Long, I As Long'设定ctl-shift-T 为该window的hotkey
bb.hByte = HOTKEYF_CONTROL Or HOTKEYF_SHIFT
bb.lByte = vbKeyT
LSet ii = bbwParam = CLng(ii.aint)
I = SendMessage(Me.hwnd, WM_SETHOTKEY, wParam, 0)
If I = 1 Then
Debug.Print "Ctl-Shift-T 为hotkey"
Else
If I = 2 Then
Debug.Print "有其他Window也用Ctl-Shift-T当Hotkey"
Else
Debug.Print "指定失败"
End If
End If
End Sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SETHOTKEY = &H32
Const HOTKEYF_SHIFT = &H1
Const HOTKEYF_CONTROL = &H2
Const HOTKEYF_ALT = &H4
Const HOTKEYF_EXT = &H8Private Type tInteger
aint As Integer
End Type
Private Type t2Byte
lByte As Byte
hByte As Byte
End Type
Private ii As tInteger
Private bb As t2BytePrivate Sub Command1_Click()
Dim wParam As Long, I As Long'设定ctl-shift-T 为该window的hotkey
bb.hByte = HOTKEYF_CONTROL Or HOTKEYF_SHIFT
bb.lByte = vbKeyT
LSet ii = bbwParam = CLng(ii.aint)
I = SendMessage(Me.hwnd, WM_SETHOTKEY, wParam, 0)
If I = 1 Then
Debug.Print "Ctl-Shift-T 为hotkey"
Else
If I = 2 Then
Debug.Print "有其他Window也用Ctl-Shift-T当Hotkey"
Else
Debug.Print "指定失败"
End If
End If
End Sub
Const WM_SETHOTKEY = &H32
Const HOTKEYF_SHIFT = &H1
Const HOTKEYF_CONTROL = &H2
Const HOTKEYF_ALT = &H4
Const HOTKEYF_EXT = &H8Private Type tInteger
aint As Integer
End Type
Private Type t2Byte
lByte As Byte
hByte As Byte
End Type
Private ii As tInteger
Private bb As t2BytePrivate Sub Command1_Click()
Dim wParam As Long, I As Long'设定ctl-shift-T 为该window的hotkey
bb.hByte = HOTKEYF_CONTROL Or HOTKEYF_SHIFT
bb.lByte = vbKeyT
LSet ii = bbwParam = CLng(ii.aint)
I = SendMessage(Me.hwnd, WM_SETHOTKEY, wParam, 0)
If I = 1 Then
Debug.Print "Ctl-Shift-T 为hotkey"
Else
If I = 2 Then
Debug.Print "有其他Window也用Ctl-Shift-T当Hotkey"
Else
Debug.Print "指定失败"
End If
End If
End Sub
我已经找到了.
不过我已经为你加分了!
谢谢你的help!
其实你的用法时对的,但是必须在form的消息处理中,捕捉wm_hotkey事件。就可以了!