1.CXXXDlg.h 中添加 #define ID_HOTKEY1 0x2411
2.消息原型声明: afx_msg LRESULT OnHotKey(WPARAM wParam, LPARAM lParam);
3.消息映射:ON_MESSAGE(WM_HOTKEY,OnHotKey)
4.注册:
BOOL bResult = RegisterHotKey(m_hWnd, ID_HOTKEY1, MOD_SHIFT | MOD_CONTROL, VK_F11);
ASSERT(bResult);
5.实现:
LRESULT CXXXDlg::OnHotKey(WPARAM wParam,LPARAM lParam)
{
switch (wParam)
{
case ID_HOTKEY1:
AfxMessageBox(_T("OnHotKey-2411"));
break;
default:
break;
}
return 0;
}
6.解除注册:
BOOL bResult = UnregisterHotKey(m_hWnd, 2411) == TRUE;
ASSERT(bResult);
MFC注册热键
最新推荐文章于 2018-11-09 10:00:43 发布