Sign in to follow this  

combo boxes

This topic is 3410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites
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
{

Share this post


Link to post
Share on other sites

  • 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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this