用RegisterHotKey ,拦WM_HOTKEY

解决方案 »

  1.   

     RegisterHotKey(this->m_hWnd,HOTKEY,MOD_ALT,VK_F1);
    BEGIN_MESSAGE_MAP(CComputerCtrlDlg, CDialog)
    //{{AFX_MSG_MAP(CComputerCtrlDlg)
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_SHUTDOWN, OnShutdown)
    ON_BN_CLICKED(IDC_REBOOT, OnReboot)
    ON_BN_CLICKED(IDC_LOGOUT, OnLogout)
    ON_BN_CLICKED(IDC_SLEEP, OnSleep)
    ON_BN_CLICKED(IDC_GO, OnGo)
    ON_WM_TIMER()
    ON_MESSAGE(WM_HOTKEY,OnHotKey)
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`手工加入的
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    //{{AFX_MSG(CComputerCtrlDlg)
    virtual BOOL OnInitDialog();
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    afx_msg void OnShutdown();
    afx_msg void OnReboot();
    afx_msg void OnLogout();
    afx_msg void OnSleep();
    afx_msg void OnGo();
    afx_msg void OnTimer(UINT nIDEvent);
    afx_msg void OnHotKey(LPARAM lParam,WPARAM wParam);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~手工加入的
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
      

  2.   

     OnHotKey()是个函数,那么函数将放在什么地方?
    应该是视图.cpp里吧。
    RegisterHotKey(this->m_hWnd,HOTKEY,MOD_ALT,VK_F1);
    这句话是否是放在函数里?
      

  3.   

      RegisterHotKey(this->m_hWnd,HOTKEY,MOD_ALT,VK_F1);
    这句话是否是放在函数里 ----OnInitialDialog()
      你看着上面哪里有相应的afx_msg就放在那里了