Solved

Detecting F10 with WM_KEYDOWN

Posted on 1998-11-12
5
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

710 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