How to use the combobox?

Anyone have an example of how to add an item to my combo box list and also how to read what is the text in the edit part of the box?

I am very new to this. Here is my combo box.

HWND combo1;

switch(message){
case WM_CREATE:

...

combo1 = CreateWindow(
"COMBOBOX","test",WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_TABSTOP |CBS_DROPDOWN,
250,350,110,20,
hwnd,(HMENU)IDC_COMBO1,0,NULL);
SendMessage(combo1, WM_SETTEXT, 0, (LPARAM) "Enter Account");

What I want is first of all to add things to my combo list, and then when they click my button I want it to find out what is the value in the combobox!

Thanks for any help!
[762 byte] By [WhorlyWhelk] at [2007-11-20 8:45:44]
# 1 Re: How to use the combobox?
Look at:

CB_ADDSTRING ( http://msdn2.microsoft.com/en-us/library/ms673142.aspx).
CB_GETCURSEL ( http://msdn2.microsoft.com/en-us/library/ms673153.aspx).
CB_GETLBTEXT ( http://msdn2.microsoft.com/en-us/library/ms673167.aspx).

Cheers
golanshahar at 2007-11-9 13:30:44 >
# 2 Re: How to use the combobox?
Oohhh man thanks! I didn't realize you used SendMessage to get stuff. ^^
WhorlyWhelk at 2007-11-9 13:31:43 >
# 3 Re: How to use the combobox?
Got another question... is there some style I need to be able to actually view the list when I click on the down arrow? Right now I am adding elements to the drop list but I can't view them, I can just hit the down arrow key to see them. :-S

combo1 = CreateWindow(
"COMBOBOX","test",WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_TABSTOP | CBS_DROPDOWN | CBS_HASSTRINGS,
250,350,110,20,
hwnd,(HMENU)IDC_COMBO1,0,NULL);
SendMessage(combo1, WM_SETTEXT, 0, (LPARAM) "Enter Account");
WhorlyWhelk at 2007-11-9 13:32:40 >
# 4 Re: How to use the combobox?
Look at:

CB_ADDSTRING (http://msdn2.microsoft.com/en-us/library/ms673142.aspx).
CB_GETCURSEL (http://msdn2.microsoft.com/en-us/library/ms673153.aspx).
CB_GETLBTEXT (http://msdn2.microsoft.com/en-us/library/ms673167.aspx).

CheersOkayyyy I used all of these. However none of them seem to get the text that is in the edit box part of the combobox. I viewed the whole list on MSDN like 10 times and cannot find anything that gets it. :-\
WhorlyWhelk at 2007-11-9 13:33:45 >
# 5 Re: How to use the combobox?
Just a little additional advice, that can make your WinAPI programmer's life a little bit easier (if you want, of course ;)).

Include in <WINDOWSX.H> then, instead of SendMessage, use ComboBox_xxx maxros defined in that header.

Examples:

ComboBox_AddString
ComboBox_GetCurSel
ComboBox_GetLBText
ovidiucucu at 2007-11-9 13:34:43 >