Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detecting F10 with WM_KEYDOWN

Posted on 1998-11-12
5
Medium Priority
?
732 Views
Last Modified: 2013-12-03
I need to detect the keypress of every single function key, and I'm having trouble with F10 because Windows automatically intercepts the F10 message to activate the menu (like an ALT press). How can I get around this?
0
Comment
Question by:HoJu
  • 3
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1416009
You could use an application-local message hook, e.g.

// this is a WH_GETMESSAGE hook
LRESULT CALLBACK HookProc   (   int     nCode,  // hook code
                                WPARAM  wParam, // removal flag
                                LPARAM  lParam  // address of structure with message
                            )
{
    PMSG    pmsg    =   ( PMSG) lParam;

    if  (   0   >   nCode   ||  PM_NOREMOVE ==  wParam)
        {
            return  (   CallNextHookEx  (   g_hhk,
                                            nCode,
                                            wParam,
                                            lParam
                                        )
                    );
        }

    if  (   WM_KEYDOWN  ==  pmsg->message  
        )
        {
            /* this one is for us, so check key state */
            if  (       0x80000000 & GetKeyState    (   VK_F10)
                )
                {
                    // signal it to application
                }
        }

// ...

}

0
 

Author Comment

by:HoJu
ID: 1416010
Hmm. That doesn't seem to work -- I wrote a hook function, and it can catch pretty much every keystroke _except_ for F10.
0
 
LVL 86

Expert Comment

by:jkr
ID: 1416011
Hmm - that's strange... i thought Windows would filter 'F10' in 'TranslateMessage()' for 'WM_KEYDOWN'. But what about 'WM_SYSKEYDOWN'?
0
 
LVL 2

Accepted Solution

by:
abesoft earned 150 total points
ID: 1416012
From the docs:
The WM_SYSKEYDOWN message is posted to the window with the keyboard focus when the user presses the F10 key (which activates the menu bar) or holds down the ALT key and then presses another key.

(This is what jkr had commented on, I think...)
0
 
LVL 86

Expert Comment

by:jkr
ID: 1416013
abesoft - yes, that's exactly what i meant ...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question