AxibugEmuOnline/virtuanessrc097-master/WndHook.cpp

77 lines
3.4 KiB
C++
Raw Normal View History

<EFBFBD><EFBFBD>//
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
//
#include "DebugOut.h"
#include "App.h"
#include "Wnd.h"
#include "WndHook.h"
// Instance
CWndHook WndHook;
BOOL CWndHook::m_bMsgFiltering = FALSE;
BOOL CWndHook::m_bMsgFilter = FALSE;
HHOOK CWndHook::m_hOldMsgFilter = NULL;
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0n0RgS(<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0L0RgSU0<EFBFBD>0f0K0<EFBFBD>0|Ts0<EFBFBD>QY0<EFBFBD>N)
void CWndHook::Initialize()
{
m_hOldMsgFilter = ::SetWindowsHookEx( WH_MSGFILTER, (HOOKPROC)MessageFilterProc, NULL, ::GetCurrentThreadId() );
}
void CWndHook::Release()
{
if( m_hOldMsgFilter ) {
::UnhookWindowsHookEx( m_hOldMsgFilter );
m_hOldMsgFilter = NULL;
}
}
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>Qt(<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0o0nf<EFBFBD>g0o0egj0D0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0L0B0<EFBFBD>0_0<EFBFBD>0)
LRESULT CALLBACK CWndHook::MessageFilterProc( INT code, WPARAM wParam, LPARAM lParam )
{
if( code < 0 ) {
return ::CallNextHookEx( m_hOldMsgFilter, code, wParam, lParam );
}
if( m_bMsgFiltering && code == MSGF_DIALOGBOX ) {
// <EFBFBD>ek0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0-NK0<EFBFBD>
if( m_bMsgFilter )
return FALSE;
m_bMsgFilter = TRUE;
LPMSG lpMsg = (LPMSG)lParam;
if( lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST ) {
if( WalkPreTranslateTree( lpMsg ) ) {
m_bMsgFilter = FALSE;
return 1L;
}
}
m_bMsgFilter = FALSE;
}
return ::CallNextHookEx( m_hOldMsgFilter, code, wParam, lParam );
// return FALSE;
}
BOOL CWndHook::WalkPreTranslateTree( MSG* lpMsg )
{
// <EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0<EFBFBD>0
HWND hWndStop = CApp::GetHWnd();
// PreTranslateMessage<EFBFBD>0<EFBFBD><EFBFBD><EFBFBD>0
for( HWND hWnd = lpMsg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd) ) {
if( hWnd == hWndStop )
break;
CWnd* pWnd = (CWnd*)::GetWindowLong( hWnd, GWL_USERDATA );
if( pWnd ) {
if( pWnd->PreTranslateMessage( lpMsg ) )
return TRUE;
}
if( hWnd == hWndStop )
break;
}
return FALSE;
}