CComboBox::GetHorizontalExtent

从组合框中检索在组合框中的列表框部分可以水平滚动的像素宽度。

UINT GetHorizontalExtent( ) const;

返回值

组合框的列表框部分的可滚动的宽度,以像素为单位。

备注

仅当组合框的列表框部分具有水平滚动条,这适用。

示例

// 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);
}

要求

Header: afxwin.h

请参见

参考

CComboBox选件类

层次结构图

CListBox::SetHorizontalExtent

CB_GETHORIZONTALEXTENT