FastKey.bas
上传用户:albinfu
上传日期:2021-08-24
资源大小:71k
文件大小:2k
- Attribute VB_Name = "FastKey"
- Public Declare Function SetWindowLong Lib "user32" _
- Alias "SetWindowLongA" _
- (ByVal hwnd As Long, _
- ByVal nIndex As Long, _
- ByVal dwNewLong As Long) _
- As Long
- Public Declare Function GetWindowLong Lib "user32" _
- Alias "GetWindowLongA" _
- (ByVal hwnd As Long, _
- ByVal nIndex As Long) _
- As Long
- Public Declare Function CallWindowProc Lib "user32" _
- Alias "CallWindowProcA" _
- (ByVal lpPrevWndFunc As Long, _
- ByVal hwnd As Long, _
- ByVal Msg As Long, _
- ByVal wParam As Long, _
- ByVal lParam As Long) _
- As Long
- '定义常数
- Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long
- Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal id As Long) As Long
- Public Const GWL_WNDPROC = (-4)
- Public Const WM_QUERYENDSESSION = &H11
- Public Const WM_CLOSE = &H10
- Public Const MOD_ALT = &H1
- Public Const MOD_CONTROL = &H2
- Public Const MOD_SHIFT = &H4
- Public Const WM_HOTKEY = &H312
- '全局变量,存放控件标志性数据
- Public preWindProc As Long, Modifiers As Long
- Public m_AllowExit As Boolean
- Public uVirtkey As Long, idHotkey As Long
- Private Type taLong
- ll As Long
- End Type
- Private Type tzInt
- lWord As Integer
- hWord As Integer
- End Type
- Public Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- If Msg = WM_HOTKEY Then
- If wParam = idHotkey Then
- Dim lp As taLong, iz As tzInt
- lp.ll = lParam
- LSet iz = lp
- If (iz.lWord = Modifiers) And (iz.hWord = uVirtkey) Then
- Form1.Visible = True
- End If
- End If
- End If
- WndProc = CallWindowProc(preWindProc, hwnd, Msg, wParam, lParam)
- End Function