Sign in to follow this  
remdul

app temporarily hangs when F10 pressed

Recommended Posts

remdul    176
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.

Share this post


Link to post
Share on other sites
ViLiO    1326
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

Share this post


Link to post
Share on other sites
Stanza    144
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.

Share this post


Link to post
Share on other sites
remdul    176
@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.

Share this post


Link to post
Share on other sites
remdul    176
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.

Share this post


Link to post
Share on other sites
mattnewport    1038
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.

Share this post


Link to post
Share on other sites
remdul    176
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this