We help IT Professionals succeed at work.

How to catch Del  and Delete key press ?

gaohong
gaohong asked
on
Medium Priority
1,331 Views
Last Modified: 2013-12-03
I have an editor from made from scrach, however, I never
get WM_KEYDOWN send to me, when Del or Delete key pressed.
I would like the use not only use backspace but also Del
and Delete key.

Any Solutions

Thank you very much
Comment
Watch Question

Commented:
Are you absolutely sure you're not getting a WM_KEYDOWN? According to the documentation you should get one with bit 24 in the flags turned on (for extended key). I believe it should be flagged as VK_DELETE character.

Author

Commented:
I am sure I did not get WM_KEYDOWN message, when Del or Delete
key is pressed. Except those two keys, all the other key press
I got WM_KEYPRESS.

It is not something I missed WM_KEYDOWN, because the message callback is never entered when Del or Delete key pressed. However, I do notice an editor control did
response to the Del or Delete key, while a normal window does not, so it must be something tricky.

Sorry I have to refuse your answer.

Commented:
TranslateMessage changes these to WM_CHAR & WM_SYSCHAR messages.
Commented:
TranslateMessage changes these to WM_CHAR & WM_SYSCHAR messages.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Are you sure, md ?  Because, neither I get WM_CHAR message when
Del or Delete key pressed.  I will try WM_SYSCHAR. Could you little bit more clear

Thanks, md

Author

Commented:
md, could not catch WM_SYSCHAR, WM_SYSKEYDOWN neither, when
Del or Delete key pressed. Any idea ?

Commented:
No, this is a new one one me.  Are you using a framework, or straight Windows?

Author

Commented:
I am using TWindow of OWL. The problem is my window does not
get notified on either Del or Delete key presses. In any of following catcher

    EvSysKeyDown()
    EvSysChar()
    EvKeyDown()
    EvChar()
However, I do notice that my editor control, did catch them,
while the TEditFile window does not (one of editor I use in my
program).

Any idea ?

Commented:
What about using a utility like Spy++ to figure out if the message gets to the window (and it's "eaten" somewhere in the code) or not?

Davide Marcato.

Commented:
This is sent to the Windows edit control directly through DispatchMessage.  The only way to get around this is to overload TApplication::ProcessMsg(MSG& msg).

Commented:
When the Delete key or the Del (.) key without NumLock is pressed, the WM_KEYDOWN message (VK_DELETE) is sent. It is not translated to WM_CHAR or WM_SYSCHAR message. When the Del (.) key with NumLock is pressed, the WM_KEYDOWN message (VK_DECIMAL) is sent and the WM_CHAR (VK_DELETE) is also sent. You should get the WM_KEYDOWN message each time a key is pressed. Check your message loop.

Author

Commented:
Thanks for all your guys comments and answer. It seems that
Application's PressMsg() eaten up the Del and Delete key.
After change, It did response to the Delete key now.

Gaohong Xie
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.