Search code examples
c++mfcwinapiatlwtl

ComboBoxEx32 (CComboBoxEx) keyboard behaviour


I have a WTL application that uses an extended combobox control (the Win32 class ComboBoxEx32) with the CBS_DROPDOWNLIST style. It works well (I can have images against each item in the box) but the keyboard behaviour is different to a normal combobox - pressing a key will not jump to the first item in the combo that starts with that letter.

For example, if I add the strings 'Arnold', 'Bob' and 'Charlie' to the combo, if I then select the combo and press 'B', then 'Bob' won't be selected.

Does anyone know how to make this work? Currently the only idea I can think of is to somehow subclass the 'actual' combobox (I can get the handle to this using the CBEM_GETCOMBOCONTROL message) and process WM_CHARTOITEM. This is a PITA so I thought I'd ask if anyone else has come across this issue before.


Solution

  • In the end I hooked the combobox control (obtained with CBEM_GETCOMBOCONTROL) and trapped the WM_CHARTOITEM message and performed my own lookup. I can post code if anyone else is interested.