15,980
社区成员




BOOL ret = m_Dlg.Create(IDD_DIALOG_MESS ,CWnd::FromHandle(::GetDesktopWindow()));// CWnd::FromHandle(m_hParent)
if(ret==0)
{
return NULL;
}
::ShowWindow(m_Dlg.m_hWnd,SW_SHOW);
LRESULT CALLBACK CMessMangerApp::GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
LPMSG lpMsg = (LPMSG) lParam;
if(AfxGetApp()->PreTranslateMessage(lpMsg))
{
lpMsg->message = WM_NULL;
lpMsg->lParam = 0L;
lpMsg->wParam = 0;
}
// Passes the hook information to the next hook procedure in
// the current hook chain.
return ::CallNextHookEx(hHook, nCode, wParam, lParam);
}
BOOL CMessMangerApp::InitInstance()
{
hHook = ::SetWindowsHookEx(
WH_GETMESSAGE,
GetMessageProc,
AfxGetInstanceHandle(),
GetCurrentThreadId());
ASSERT (hHook);
return CWinApp::InitInstance();
}
int CMyApp::ExitInstance()
{
UnhookWindowsHookEx((HHOOK)hHook);
return CWinApp::ExitInstance();
}