怎么能让VB程序能像QQ那样隐藏后用热键调出来呀?

来源:百度知道 编辑:UC知道 时间:2024/05/20 09:24:04
怎么能让VB程序能像QQ那样隐藏后用热键调出来呀?

注册热键
''窗体中
Option Explicit

Private Sub Form_Load()
Dim ret As Long
''记录原来的window程序地址
preWinProc = GetWindowLong(Me.hWnd, GWL_WNDPROC)
''用自定义程序代替原来的window程序
ret = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf wndproc)
idHotKey = 1 ''in the range &h0000 through &hBFFF
Modifiers = MOD_ALT ''辅助键为Alt
uVirtKey1 = vbKeyQ ''注册的热键为Alt+Q
''注册热键
ret = RegisterHotKey(Me.hWnd, idHotKey, Modifiers, uVirtKey1)
If ret = 0 Then
MsgBox "注册热键失败,请使用其它热键!", vbCritical, "错误"
End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim ret As Long
''取消Message的截取,使之送往原来的window程序
ret = SetWindowLong(Me.hWnd, GWL_WNDPROC, preWinProc)
Call UnregisterHotKey(Me.hWnd, uVirtKey1)
End Sub

''模块中

''以下程序放在模块中
Optio