|
-
November 8th, 2005, 03:56 PM
#1
CComboBox question...
Hi,
I create CComboBox control dynamically in my program using the .Create() method, I fill the control with data, but when I run the program and click on the combo-box to expand its list - I can see only the first option and NO list is opened, how can I define the list length ?
Thanks
-
November 8th, 2005, 04:42 PM
#2
Re: CComboBox question...
Just use SetItemHeight()
MSDN Code:
Code:
// The pointer to my combo box.
extern CComboBox* pmyComboBox;
// Set the height of every item to be the
// vertical size of the item's text extent.
CString str;
CSize sz;
int dx=0;
CDC* pDC = pmyComboBox->GetDC();
for (int i=0;i < pmyComboBox->GetCount();i++)
{
pmyComboBox->GetLBText( i, str );
sz = pDC->GetTextExtent(str);
pmyComboBox->SetItemHeight( i, sz.cy );
}
pmyComboBox->ReleaseDC(pDC);
"Live only for tomorrow, and you will have a lot of empty yesterdays today."
-
November 8th, 2005, 04:49 PM
#3
Re: CComboBox question...
I think you are looking for SetDroppedWidth() and SetHorizontalExtent().
-
November 9th, 2005, 03:59 AM
#4
Re: CComboBox question...
You can specify the height of the drop down list by using the CB_SETMINVISIBLE message or the ComboBox_SetMinVisible macro, however that is for Windows XP or later only.
You can also change the height of the listbox by using SetWindowPos.
Last edited by Marc G; November 9th, 2005 at 04:01 AM.
-
November 9th, 2005, 04:02 AM
#5
Re: CComboBox question...
CB_SETMINVISIBLE is ok, but it requires Windows XP. For a more generic solution use the code bellow:
Code:
// assuming cbo is a CComboBox
CRect rect;
cbo.GetWindowRect( rect);
rect.bottom += 100;
cbo.MoveWindow( rect);
Basically, setting the Combo's height affects the height of the drop list.
Har Har
-
November 9th, 2005, 04:11 AM
#6
Re: CComboBox question...
 Originally Posted by PadexArt
CB_SETMINVISIBLE is ok, but it requires Windows XP. For a more generic solution use the code bellow:
Exactly, that's why I edited my post immediately after posting it
-
November 9th, 2005, 04:13 AM
#7
Re: CComboBox question...
 Originally Posted by Marc G
Exactly, that's why I edited my post immediately after posting it 
I was adding my answer at the same time (11:01 - 11:02).
Har Har
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|