How to get string from combo box selection

I'm looking to get the string from a combo box selection. I was hoping it would work similarly to getting the string from a list box selection but it doesn't look to be that simple. Would have been nice if I could have swapped out LB_GETTEXT with something like CB_GETTEXT but no such luck :).

I know how to get the combo box selection index (CB_GETCURSEL). If there isn't a direct way to get a combo box's current selection text, would I be able to use that index to get at it?
I was hoping it would work similarly to getting the string from a list box selection but it doesn't look to be that simple.

Yes, it is.

As listed on

ComboBox Control Messages
http://msdn.microsoft.com/en-us/library/windows/desktop/ff485901%28v=vs.85%29.aspx

CB_GETLBTEXT
CB_GETLBTEXTLEN

to get the text/length from the ComboBox's list

You can also use

WM_GETTEXT
WM_GETTEXTLEN

to get the text/len from the Edit control

(a ComboBox is a combination of a Edit control and a ListBox...)

Andy
Last edited on
Thank you for that link!! The main trouble I have when I search is that first of all, I are still learning the terminology and it is hard to find something when you don't know what to call it. That means I have to resort to terms that are so common that the results that are returned are next to useless. Another problem is that when I do find a solution, it is for those controls that are created via classes which doesn't help me since I'm not using those.

But that link you sent me lets me find the kinds of solutions I need :).
Topic archived. No new replies allowed.