Posted on 2009-04-26
Medium Priority
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

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

Expert Comment

ID: 24255434

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

DanRollins earned 1500 total points
ID: 24287774
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

ID: 31574737
The Sublinks helped a lot

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

864 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