Click to See Complete Forum and Search --> : How to create ComboBox dynamically???


sayoyo
May 12th, 1999, 02:14 PM
Hi,

I try to create a CComboBox dynamically without using the ressource editeur like this:

r2.bottom = 30;
r2.left = 10;
r2.right = 150;
r2.top = 10;
pNewComboBox = new CMyComboBox;
pNewComboBox->Create(WS_VISIBLE|CBS_DROPDOWNLIST,r,AfxGetMainWnd(),5003);
pNewComboBox->AddString("A");
pNewComboBox->AddString("B");
pNewComboBox->AddString("C");

But at runtime, I try to see the list(A,B,C), it doesn't work,
I can't see the list because the dropdown list is the same size
than the ComboBox. How can I set the size of dropdowm list?
or How can i set the combobox correctely?

Thanks

pherweg
May 13th, 1999, 07:45 AM
Hi,

the rectangle you pass to the Create-function specifies the size of dropdown list. If you want to set the combobox size use the member-function SetItemHeight of CComboBox.

For example
pNewComboBox->SetItemHeight(-1,15);
sets the height of the closed combobox.

Hope i gave you the needed informations.
Good Luck!

Peter

P.S.: You initialized a variable called r2. But in function call you called it r.