Jump to content
  • Advertisement
Sign in to follow this  
Super Llama

[C++] WM_CHAR and the delete key

This topic is 2666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to capture data for a textbox object in my sprite engine, and so far I've been using WM_CHAR to get the characters I need. The problem is, WM_CHAR doesn't seem to generate a message when I press delete (or any other extended key) even though MSDN seems to imply that it does. Am I going to have to switch to WM_KEYDOWN?

Share this post


Link to post
Share on other sites
Advertisement
You need to set a special style for the window for the extra characters to be sent. Something like "WANTSCHAR", don't remember the exact wording.

Share this post


Link to post
Share on other sites
Didn't seem to work, no WM_CHAR messages were generated when I pressed delete. I ended up just implementing WM_KEYDOWN above my WM_CHAR case and breaking if the LPARAM shows that the bit is not extended-- therefore, extended keys are sent to the same set of code, and non-extended keys are handled nicely and already translated for the keyboard by WM_CHAR. Works pretty well, though I had to add an additional wp+=1024 in the WM_KEYDOWN case so that my keycode processor could tell the difference between the delete key and the period key.

Share this post


Link to post
Share on other sites
DELETE isn't a character, it's a key. Your solution of using WM_KEYDOWN is the right thing to do.

In general you need to use WM_CHAR for reading text and WM_KEY* for reading keys. For some reason a lot of people really want to use only one or the other. Resist that impulse, you inevitably run into problems like this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!