Software Archive
Read-only legacy content
17061 Discussions

getting Function keys press

davidgraham
Beginner
293 Views
I am trying to get function keys from key presses.
if I press F12, i is returned as 123 below, and F11 is returned as 122, etc,
but when I press F10 I don't get anything, it doesn't go to this routine.
I cannot think why F10 is treated differently (maybe it's something about my code?)
Any suggestions?
Thanks,
David
 
lret=PeekMessage (msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_NOREMOVE) 
if (lret) then 
	i=msg%wParam 
end if 
0 Kudos
2 Replies
davidgraham
Beginner
293 Views
I did some more investigation on this and under WM_KEYDOWN I found a mention that f10 is special.

Default Action
If the f10 key is pressed, the DefWindowProc function sets an internal flag. When DefWindowProc receives the WM_KEYUP message, the function checks whether the internal flag is set and, if so, sends a WM_SYSCOMMAND message to the top-level window. The wParam parameter of the message is set to SC_KEYMENU.

I don't understand it.
How can I tell if f10 has been pressed?

Thanks,
David
0 Kudos
Jugoslav_Dujic
Valued Contributor II
293 Views
F10 is considered a "system-reserved" key (similarly to Alt+F4 combination); a brief examination with spy++ shows that (in notepad at least, but not in VS, where it is mapped to something) F10 generates a WM_SYSKEYDOWN in child and WM_SYSCOMMAND/SC_KEYMENU in parent, i.e. it has the same effect as Alt, but, true, WM_KEYDOWN isn't received.

You might try installing a WH_KEYBOARD keyboard hook (I don't guarantee that will work with F10 either; i think it will). See sample at recent thread "QuickWin, Accelerator Keys".

Jugoslav
0 Kudos
Reply