CComboBox::GetHorizontalExtent

UINT GetHorizontalExtent( ) const;

Return Value

The scrollable width of the list-box portion of the combo box, in pixels.

Remarks

Retrieves from the combo box the width in pixels by which the list-box portion of the combo box can be scrolled horizontally. This is applicable only if the list-box portion of the combo box has a horizontal scroll bar.

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 only if the current extent is not large enough.
if (pmyComboBox->GetHorizontalExtent() < dx)
{
   pmyComboBox->SetHorizontalExtent(dx);
   ASSERT(pmyComboBox->GetHorizontalExtent() == dx);
}

CComboBox OverviewClass MembersHierarchy Chart

See Also   CListBox::SetHorizontalExtent, CB_GETHORIZONTALEXTENT