is it possible for a DialogBox to catch WM_KEYDOWN and similar messages no matter which control has the focus?
is it possible for a DialogBox to catch WM_KEYDOWN and similar messages no matter which control has the focus?
Definitely. One solution in MFC is to override PreTranslateMessage(). In Win32 API, one solution is hooking.
Kuphryn
ah, hooking..anyone care to give more info on that?
as for MFC, since its basically an api wrapper, how would the PreTranslateMessage be implemented in win32?
Check out SetWindowHook() and SetWindowHookEx().
Kuphryn
PreTranslateMessage()'s equivalent in Win32 would be placing code in the message loop, before the message is translated and dispatched, or just hooking the window procedure. Check out the functions that kuphryn mentioned.how would the PreTranslateMessage be implemented in win32?
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
hm, MSDN doesnt have SetWindowHook() although SetWindowsHookEx() is there. Unfortunately we can't get to the message loop of a DialogBox..
Get the HWND of the dialog window and then hook it's window procedure using SetWindowLong(). That's how I used to do it.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials