Click to See Complete Forum and Search --> : Prevent F10 from acting like ALT


teleplayr
April 20th, 2003, 01:57 PM
I have an app in which I'd like to use F10 for something. The problem is, everytime I hit F10, it acts like ALT and focus goes up to the menu bar.

I'm looking for a way to disable this behavior for my entire app. There can be many windows open in different combinations.

The only thing I can think of is setting a keyboard hook, but that seems a long way to go to use F10, and since I want it to happen for all my windows, it would get cumbersome.

I'm using GetAsyncKeyState to test whether F10 is pressed, and that works fine. It's just the window loses focus at the same time.

Help is greatly appreciated :) Thanks!

-Joe

poccil
April 20th, 2003, 04:55 PM
It is inherent for Windows to use the F10 key in that manner. When processing the F10 key in the WM_KEYDOWN and WM_KEYUP messages, return zero to prevent Windows from processing the F10 key.

teleplayr
April 20th, 2003, 10:16 PM
I had thought of that, but WM_KEYDOWN and WM_KEYUP are only generated for non-system keys. F10 does not generate these (I tested it). It actually generates a WM_SYSCOMMAND message, but so does ALT.

What I ended up doing is just setting up a keyboard hook and returning nonzero when the F10 comes in. My app never sees the F10, but I am able to poll for it using GetAsyncKeyState, so it works perfectly.

-Joe