CComboBox::SetHorizontalExtent
void SetHorizontalExtent( UINT nExtent );
Parameters
nExtent
Specifies the number of pixels by which the list-box portion of the combo box can be scrolled horizontally.
Remarks
Sets the width, in pixels, by which the list-box portion of the combo box can be scrolled horizontally. If the width of the list box is smaller than this value, the horizontal scroll bar will horizontally scroll items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden or, if the combo box has the CBS_DISABLENOSCROLL style, disabled.
Example
// The pointer to my combo box.
extern CComboBox* pmyComboBox;
// Find the longest string in the combo box.
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);
if (sz.cx > dx)
dx = sz.cx;
}
pmyComboBox->ReleaseDC(pDC);
// Set the horizontal extent so every character of all strings can
// be scrolled to.
pmyComboBox->SetHorizontalExtent(dx);
CComboBox Overview | Class Members | Hierarchy Chart
See Also CComboBox::GetHorizontalExtent,