Solved

Detecting F10 with WM_KEYDOWN

Posted on 1998-11-12
5
661 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 50 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio Exe Issue, 12 30
Windows 10 Scheduled Tasks 11 89
Which Microsoft MSDN Package Is The One I need? 3 45
Where did System.Data.Objects go? 2 29
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

831 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