Solved

Detecting F10 with WM_KEYDOWN

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now