拿句柄不能这样用HWND myallen = (HWND)::GetModuleHandle(NULL);
第一步(这里小写好像不好使) ::RegisterHotKey(this->m_hWnd, 0x1234, MOD_CONTROL, 'G'); 第二步重写虚函数(不是响应消息)
BOOL CMFCApplication2Dlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
if ((pMsg->message == WM_HOTKEY) && (pMsg->wParam == 0x1234))
{
// HWND myallen = (HWND)::GetModuleHandle(NULL);
if (::IsWindowVisible(m_hWnd) == TRUE ){
ShowWindow(SW_HIDE);
}
else {
ShowWindow(SW_SHOW);
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}