Freigeben über


CComboBox::GetHorizontalExtent

Ruft das Kombinationsfeld die Breite in Pixel ab, durch die der Listenfeldbereich des Kombinationsfelds horizontalen Bildlauf durchgeführt werden kann.

UINT GetHorizontalExtent( ) const;

Rückgabewert

Die scrollbaren Breite des Listenfeldteils des Kombinationsfelds, in Pixel.

Hinweise

Dies gilt nur, wenn der Listenfeldbereich des Kombinationsfelds eine horizontale Bildlaufleiste vorhanden.

Beispiel

// Find the longest string in the combo box.
CString strText;
CSize   sz;
UINT    dxText = 0;
CDC*    pDCCombo = m_pComboBox->GetDC();
for (int i = 0; i < m_pComboBox->GetCount(); i++)
{
   m_pComboBox->GetLBText(i, strText);
   sz = pDCCombo->GetTextExtent(strText);

   if (sz.cx > (LONG)dxText)
     dxText = sz.cx;
}
m_pComboBox->ReleaseDC(pDCCombo);

// Set the horizontal extent only if the current extent is not large enough. 
if (m_pComboBox->GetHorizontalExtent() < dxText)
{
   m_pComboBox->SetHorizontalExtent(dxText);
   ASSERT(m_pComboBox->GetHorizontalExtent() == dxText);
}

Anforderungen

Header: afxwin.h

Siehe auch

Referenz

CComboBox-Klasse

Hierarchiediagramm

CListBox::SetHorizontalExtent

CB_GETHORIZONTALEXTENT