把RegisterHotKey、UnregisterHotKey的代码贴出来

解决方案 »

  1.   

    SetWindowLong F.hWnd, GWL_WNDPROC, PreWinproc
    UnregisterHotKey F.hWnd, uVirtkey
    这两句调换位置
      

  2.   


    两个API来的.
    Private Declare Function RegisterHotKey Lib "user32" _
            (ByVal hWnd As Long, _
             ByVal id As Long, _
             ByVal fskey_Modifiers As Long, _
             ByVal vk As Long) As LongPrivate Declare Function UnregisterHotKey Lib "user32" _
            (ByVal hWnd As Long, ByVal id As Long) As Long
      

  3.   

    SetWindowLong F.hWnd, GWL_WNDPROC, PreWinproc
    UnregisterHotKey F.hWnd, uVirtkey调换位置还是出错了!
      

  4.   

    Private OldFunPtr as longSub SetForm(F As Form, Key As Long)
        ……
        
        '代替WINDOWS原地址
        OldFunPtr=SetWindowLong(F.hWnd, GWL_WNDPROC, AddressOf Wndproc)
        
        'SET HOTKEY
        idHotkey = 1
        
        ……
    End Sub
    '退出时用了
    Function Unhotkey()
        UnregisterHotKey frmSend.hWnd, idHotkey
        Call SetWindowLong(F.hWnd, GWL_WNDPROC, OldFunPtr)
    End Function