Catching Enter Keypress from a CComboBox
Once a user types something in to my CComboBox (within a CDialog sub开发者_如何学Cclass) and presses Enter, I would like to add what they've written to the list of options, and do some other handling. How do you do that in MFC?
Here is some information you might find useful:
The
ENTER
key, by default, is only processed by the combo box when the drop list is open, and in this case it has the same effect as a mouse click and makes the selection. A Simple combo box does not process theENTER
key at all and is passed to the parent dialog. If you wish to handle theENTER
key in any other way the combo box will need to be subclassed and handler written for the purpose. You may like to check out Implementing an autocompleting Combobox - By Chris Maunder as a starting point to which the handler can be added.
精彩评论