WM_KEYDOWN not working in MSWWindowProc Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
LeRoi
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Oct 01, 2008 1:39 pm

WM_KEYDOWN not working in MSWWindowProc

Post by LeRoi » Wed Oct 01, 2008 2:37 pm

Hi all,

I've got a little problem with the MSWWindowProc-Function.
I want to keep track of the users keypresses even they're not in the active window, so I want to catch the WM_KEYDOWN Message in the function. But somehow it's not working. Things like WM_SIZE are working nevertheless. Is this a bug or I have to use another way of catching this events?
Here's my Code:

Code: Select all

WXLRESULT MyFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
	
	switch(message){
		case WM_SIZE:
			// do something (working)
			
			break;
		case WM_KEYDOWN:
                        // handle keypress (not working)
			break;
	}
  return wxFrame::MSWWindowProc(message,wParam,lParam);
};//MSWWWindowProc
Regards LeRoi

User avatar
doublemax
Moderator
Moderator
Posts: 15921
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax » Wed Oct 01, 2008 2:55 pm

in that method you receive only messages that are meant for that particular window.

If you want to catch key presses globally inside your application, check this:
http://wiki.wxwidgets.org/Catching_key_events_globally

For system-wide hotkeys, there is:
http://docs.wxwidgets.org/stable/wx_wxw ... sterhotkey
(MSW only)

If you need to catch all keypresses system-wide, you have to use Windows hooks:
http://msdn.microsoft.com/en-us/library/ms644990.aspx
Use the source, Luke!

LeRoi
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Oct 01, 2008 1:39 pm

Post by LeRoi » Wed Oct 01, 2008 3:37 pm

Thanks, I found an example for SetWindowsHookEx() which looks like it will work.

LeRoi

Post Reply