Posted on 2009-04-26
Last Modified: 2013-11-20

I use a ACCELERATOR key "VK_SPACE" in my software. Works great. But now I have a edit field in my dialog and it is impossible to write a space inside this cause the VK_SPACE is "Blocked" by the ACCELERATOR function.
I want now to dactivate the ACCELERATOR while the edit field has focus, but where can I set this?
I have a value "nameEdit1.isFocused = true/false"  where I can check but I do not now in what function i can "disable" the ACCELERATOR tempory.


Question by:Ocrana
    LVL 19

    Expert Comment

    In my opinion the best solution is to use a different accelerator key, i.e. CTRL-SPACE
    LVL 4

    Expert Comment


    maybe you can use a global variable.
    When the edit field gets the focus you set this to TRUE and to FALES if the focus is removed.

    In the accelerator you can check this variable.

    LVL 49

    Accepted Solution

    I agree that VK_SPACE is not as good choice for an accelerator key.  However, I can also imagine special-case situations where it might be useful.
    It looks like the only way to modify an Accelerator table is to load a new one.  I suppose you could make to ACCELERATOR resources.  Then you could check for focus gain/loss of the edit control (as suggested by StefanKittel) and call
    to load the appropriate accelerator table.  
    There are other techniques, including overriding CWinApp::ProcessMessageFilter as described here:
    you could then check for an internally-set boolean or otherwise sense status and check the MSG structure to see if the VK_SPACE was coming in and skip the call to TranslateAccelerator() in that case.

    Author Closing Comment

    The Sublinks helped a lot

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    How to determine file rename from EventLog ? 2 33
    maxBlock challenge 30 89
    has22 challenge 11 56
    a reliable reference for c+11? 3 33
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    733 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

    19 Experts available now in Live!

    Get 1:1 Help Now