Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So, many WinAPI controls have a very useful feature - you can select an item in Listbox, ListView, Combobox by typing first several letters. You can try it out: just open your windows calculator, hit Ctrl+U to enable converting units view and in the top combobox start typing slowly "press". You will see, that as you type another letter the combobox selection changes accordingly.
For some reason a newly created combobox selects by first letter only.

My question is - is there a way to enable this feature (selecting by typing several letters) after combobox was created and how do i avoid sorting (because i don't need it)?

What I have tried:

So i used Spy++ and figured that Windows calculator combobox has styles CBS_SORT. That i believe the style that enables selecting by several letters, but you must set it on creation of the combobox otherwise it won't work. Also it sorts the strings in combobox which is not desired sometimes.
Posted
Updated 25-Apr-23 21:53pm

1 solution

 
Share this answer
 
v2
Comments
Avtem 26-Apr-23 4:48am    
Thanks for the answer, but this is .Net, not WinAPI. i've read the link you provided and it doesn't have any WinAPI-related clues unfortunately.
Richard MacCutchan 26-Apr-23 4:58am    
Sorry, see my update.
Avtem 26-Apr-23 5:04am    
Hm, so you would have to subclass the combobox windows procedure, catch all WM_CHAR messages and in there send messages CB_FINDSTRING to find out whether there any matching items and if there is, set the combobox index?
Richard MacCutchan 26-Apr-23 5:06am    
No, I would use one of the CBN_??? notoification messages to determine when to use this.
Avtem 26-Apr-23 5:12am    
Hm, unfortunately i don't see such notification: Combobox notifications
Also i just realized simply modifying WM_CHAR messages won't work because you have to keep track of the characters, reset it after a certain amount of time, etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900