Skip to main content
GameDev.net gamedev.net
🔒 Locked

Win32 ComboBox

Started by Melraidin Jun 18, 2002 at 4:35 PM 6 replies 400+ views
Original Post
Melraidin
Melraidin
Well, I''ve managed to waste far too much time trying to sort this stuff out on my own. I''m creating an app in VC++ 6.0 (no MFC), and have the dialog I''d like displayed created fine. As well, I''m adding strings to my combo box using the CB_ADDSTRING message. This seems to work fine, as when I do a SendMessage with CB_SETCURSEL it displays the string in the edit box fine. Now, my problem: When I click on the drop down arrow, nothing displays. It shows a slight black line underneath the combo box, but none of the items I''ve added. Can anyone help me with this? I haven''t been able to sort out how to do this from the MSDN site, even after checking all the CB msgs... Here''s the code from my WM_INITDIALOG handler:
  
			char szTemp [ 32 ], szTemp2 [ 32 ];
			HWND ComboBox = GetDlgItem ( hDialog, IDC_HOUR1 );

			CenterWindow ( hDialog );

			SendMessage ( ComboBox, CB_RESETCONTENT, 0, 0 );

			for ( int a = 1; a < 13; a++ )
			{
				itoa ( a, szTemp, 10 );

				strcpy ( szTemp2, szTemp );

				strcat ( szTemp2, " AM" );

				SendMessage ( ComboBox, CB_INSERTSTRING, a - 1, (LPARAM)szTemp2 );

				strcpy ( szTemp2, szTemp );

				strcat ( szTemp2, " PM" );

				SendMessage ( ComboBox, CB_INSERTSTRING, a + 11, (LPARAM)szTemp2 );
			}

			SendMessage ( ComboBox, CB_SETCURSEL, 0, NULL );

			return ( true );
  
IndirectX
IndirectX
Increase the height of the combobox. In other words, size it as a listbox, not as an edit control.
---visit #directxdev on afternet <- not just for directx, despite the name
Melraidin
Melraidin
Sorry, I''m not sure I quite get you on that... Ummm... how would I size it as a list box? What msg would I send? I''m extremely new to working with Windows controls, so I''m a bit behind here. Could you possibly post any code to demonstrate? I have tried sending a msg as:

SendMessage ( ComboBox, LB_SETITEMHEIGHT, 0, 32 );

With no discernable difference.
Melraidin
Melraidin
Perhaps there''s something I''m missing in WM_COMMAND? Anything that could control whether the items are displayed?
IndirectX
IndirectX
If you''re creating the combobox in the resource editor, select it and drag its lower edge down. If you''re creating it via CreateWindow, increase Height parameter.
---visit #directxdev on afternet <- not just for directx, despite the name
Colin Jeanne
Colin Jeanne
Since your combobox was made in the resource editor, in the resource editor click on the down arrow of the combo box and resize its height that way.



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm
Melraidin
Melraidin
Good lord... I can''t believe I spent so bloody long trying to fix that. Thanks, it worked perfectly. Just as a side note, isn''t there usually some sort of hint to do this sort of thing around? I checked all the context sensitive help screens in the resource editor and couldn''t find a thing. So simple.... Gotta remember to use the mouse more often.
Colin Jeanne
Colin Jeanne
You''re not the only one who has a hard time with that when using a combo box for the first time. I would have spent hours searching if Winprog didn''t warn me about it first.



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

Topic Locked

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

Sign in to reply to this topic.