app temporarily hangs when F10 pressed

Started by
6 comments, last by remdul 17 years, 1 month ago
Hi, My program apears to hang temporarily when the F10 key is pressed. The CPU usage drops to 0% (otherwise runs at 99%). Once a mouse button is pressed or other key (including F10) it regains focus again. Just moving the mouse doesn't re-focus it. The title bar remains blue (the window appears focused, nothing changes visually), the program just stops doing everything until it regains focus again. This happens on Windows XP SP2 with no other software running. The keyboard + mouse input is received through DirectInput (otherwise doing nothing fancy). Now, I could put a SetFocus() in the F10 key down event code (which currenly doesn't do anything) but I'd like to know what could be causing this in the first place... It isn't some sort of vague global keyboard shortcut (like Print Screen), or is it? Thanks.
Advertisement
For me, I have the exact same behaviour when pressing F10 but that is because F10 is my FRAPS "Screen Capture Hotkey" button [smile]

Are you also running FRAPS?

Regards,
ViLiO
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
F10 is apparently a shortcut in windows for putting the focus on the menu bar.
Unlike all of the other F# keys, pressing F10 will always carry an ALT key modifier. Why? I have no idea. But pressing F10 results in ALT-down, F10-down, F10-up, ALT-up going through. The ALT key modifier may be triggering a system menu, taking focus away from your app until you click in the window with our mouse to regain focus.
@ViLiO: Nope.

@Vorpy: I doubt it. In that case the window would visually lose focus, plus the program should keep running. Like I mentioned, the CPU usage drops to zero. Its effectively hanging. My program pauses when it looses focus, yet when I return the it appears the input has been registered and processed. My guess is that Windows blocks all window redraws.

@Stanza: Sounds interesting, but I'm not sure how it is tied to this problem. I'm investigating this now.
Oh well that was quick!

Windows generates an WM_SYSKEYUP and WM_SYSKEYDOWN message when F10 is pressed. I haven't been able to find out why (I think Stanza could be right about the menu thing).

Simply ignore those two messages in the WndProc message loop and F10 works just like the other F-keys. But note that you'll need to handle ALT-F4 and the like manually.
Try hitting F10 in any Windows app (e.g. in your browser right now) and you'll find it highlights the file menu. If you don't have a menu bar in your app or it's hidden I guess you get stuck in some message handling loop until you bring focus back.

Game Programming Blog: www.mattnewport.com/blog

Something like that yeah, but I wonder why. It's one of those things that should be left to the programmer, but I guess Microsoft considers it an integer part of the window object.

This topic is closed to new replies.

Advertisement