0

I am using CComboBox control. When I type some characters in it and check which letter is typed in(in PreTranslateMessage()), then I always get capital letter in its message's wParam. My CComboBox control does not have uppercase property TRUE. Why this is happening?

Sam L
  • 31
  • 6
  • 2
    You are probably checking for WM_KEYDOWN, and getting a Scan Code (identifying the physical key you pressed). You need to check for WM_CHAR. Why do you use `PreTranslateMessage` instead of a normal message handler? – peterchen Aug 06 '15 at 12:29
  • How would a CComboBox property "uppercase" affect the messages sent to it? That property can only affect what the combobox does with the messages it receives. (Which is: on receipt of `WM_CHAR('a')` behave as if you received `WM_CHAR('A')`) – MSalters Aug 06 '15 at 12:38
  • @peterchen: Yes I am checking in WM_KEYDOWN. Got the point :) thanks – Sam L Aug 06 '15 at 13:00
  • @MSalters: Got the point :) thanks. I thought the property might change the input also. – Sam L Aug 06 '15 at 13:01

1 Answers1

1

Keys are funny things. What's the default state, lowercase or uppercase?

If you look at your keyboard, most likely the physical keys have uppercase letters on them. Default: uppercase

When you type in keys, you need to hold the shift key to create upper keys, without the shift keys you get lower case. Default: lowercase

As an alternative, you can use the Caps Lock key. Caps Lock is normally off . Default: lowercase.

The untranslated key presses sent to your application use VK_A - VK_Z keycodes. VK_A is 'A' not 'a'. Default: uppercase. Caps lock and shift are applied later, in translation.

This could have been designed consistently, but it wasn't, and now we're stuck with the mess to be backwards compatible. If you want the "normal" keyboard behavior, don't try to exactly replicate the OS behavior. There's stuff like "Sticky Keys" (hold shift to get Caps Lock-like behavior) which you might not even know. Instead, use the end result from the OS. For Windows, that's WM_CHAR.

MSalters
  • 173,980
  • 10
  • 155
  • 350