Skip to main content
gamedev.net
🔒 Locked

combo boxes

Started by wforl 4 replies 950+ views
Original Post
wforl
wforl
I seem to be having a problem with the combo box i created in the dialog editor using the toolbox The combo box when running doesn't seem to show any of the strings i added. Ive double checked the ID's are correct, and count always seems to be 0, and @err,hr doesn't show anything other than OK, any ideas?


static const char* NotUsed = "**";

switch( msg )
	{
case WM_INITDIALOG:

		//lights
		handle = GetDlgItem(hwnd,IDC_COMBOBOX_LIGHTS);
		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM) "Light1");
		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM) "Light2");
		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCSTR) "Light3");
		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCSTR) NotUsed2);
		count = SendMessage(handle, CB_GETCOUNT, 0, 0);

		return 0;
}

staticVoid2
staticVoid2
check if its returning an error first:

switch(SendMessage(handle, CB_ADDSTRING, 0, (LPARAM) "Light1")){   case CB_ERRSPACE:     // not enough space to store string     break;    case CB_ERR:       // error        break;   default:      // something else{
Mike nl
Mike nl

  • Are you sure the IDC_COMBOBOX_LIGHTS is correct?

  • Is this on the correct dialog?

  • Try adding unicode strings instead (prefix the literals with L and cast to LPTSTR).

  • What are the styles (owner-drawn? has strings?) for the combobox (post the line from the .rc file)?

  • Try printing the return values of the SendMessages to check for errors.

  • If this is a drop-down combobox, make sure the height of the control is enough to fit several lines of text (otherwise they're clipped).

Million-to-one chances occur nine times out of ten!
wforl
wforl
I tried all of that still no luck :(

Are you sure the IDC_COMBOBOX_LIGHT is correct? - Yes,

 CONTROL         "",IDC_COMBOBOX_LIGHT,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,202,120,50


Is this on the correct dialog? - yes

Try adding unicode strings instead (prefix the literals with L and cast to LPTSTR) - no luck

//lights		handle = GetDlgItem(hwnd,IDC_COMBOBOX_LIGHT);		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM) "Lig");		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM) "Li");		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPTSTR) L"Li");		SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)(LPCSTR) NotUsed2);		count = SendMessage(handle, CB_GETCOUNT, 0, 0);


What are the styles (owner-drawn? has strings?) for the combobox (post the line from the .rc file)?

 CONTROL         "",IDC_COMBOBOX_LIGHT,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,202,120,50


Try printing the return values of the SendMessages to check for errors - always OK

If this is a drop-down combobox, make sure the height of the control is enough to fit several lines of text (otherwise they're clipped) - changed height
MJP
MJP
You're creating a extended combo box, not a regular combo box. You have to insert items, rather than simply adding strings. See CBEM_INSERTITEM.
wforl
wforl
ah yes, thankyou

I shall try to look at the .rc a lot more often, dont know how it became extended though, as i only created a standard combo box, anyway i remade a standard combo and all is good.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.