fix generation of wxEVT_CHAR_HOOK events which, incredibly, seems to have never worked because of incorrect parameter being passed to SetWindowsHookEx()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59700 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-21 16:11:06 +00:00
parent c00ee75726
commit 23c26b99e0

View File

@@ -6287,28 +6287,8 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd)
// Windows keyboard hook. Allows interception of e.g. F1, ESCAPE
// in active frames and dialogs, regardless of where the focus is.
static HHOOK wxTheKeyboardHook = 0;
static FARPROC wxTheKeyboardHookProc = 0;
int APIENTRY _EXPORT
wxKeyboardHook(int nCode, WORD wParam, DWORD lParam);
void wxSetKeyboardHook(bool doIt)
{
if ( doIt )
{
wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
GetCurrentThreadId()
// (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
);
}
else
{
UnhookWindowsHookEx(wxTheKeyboardHook);
}
}
int APIENTRY _EXPORT
int APIENTRY
wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
{
DWORD hiWord = HIWORD(lParam);
@@ -6352,6 +6332,29 @@ wxKeyboardHook(int nCode, WORD wParam, DWORD lParam)
return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam);
}
void wxSetKeyboardHook(bool doIt)
{
if ( doIt )
{
wxTheKeyboardHook = ::SetWindowsHookEx
(
WH_KEYBOARD,
(HOOKPROC)wxKeyboardHook,
NULL, // must be NULL for process hook
::GetCurrentThreadId()
);
if ( !wxTheKeyboardHook )
{
wxLogLastError(_T("SetWindowsHookEx(wxKeyboardHook)"));
}
}
else // uninstall
{
if ( wxTheKeyboardHook )
::UnhookWindowsHookEx(wxTheKeyboardHook);
}
}
#endif // !__WXMICROWIN__
#ifdef __WXDEBUG__