-
Add String To Combobox?
Hi,
I have created a combo box:
hWndServer = CreateWindow("COMBOBOX", "", WS_CHILD | WS_VISIBLE | CBS_DROPDOWN
,80, 30,
200, 20, hWnd, (HMENU)ID_SERVER, hInstance, NULL);
That works fine. How do i add strings to the combo box? i assume i use send message.
And also do i just use GetWindowText() to get the current selection?
Thanks
TNT
-
You can send your combo box an CB_ADDSTRING message to add a string -
SendMessage(hWndServer,CB_ADDSTRING,0,(LPARAM) yourString);
and get the selected item's index with CB_GETCURSEL -
int theIndex = SendMessage(hWndServer,CB_GETCURSEL,0,0);
You can then get the text that corresponds with this index by sending a CB_GETLBTEXT message with your WPARAM as the index number and the LPARAM as the buffer to recieve the text (if you need the length of text you can send a CB_GETLBTEXTLEN message).