本文整理汇总了C++中CListBox::SetHorizontalExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::SetHorizontalExtent方法的具体用法?C++ CListBox::SetHorizontalExtent怎么用?C++ CListBox::SetHorizontalExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CListBox
的用法示例。
在下文中一共展示了CListBox::SetHorizontalExtent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetHorizExtentListBox
/**************************************************************************************
Function Name : SetHorizExtentListBox
Input(s) : CListBox& omListBox
Output : void
Functionality : Sets the Listbox scroll to an extent so as to view the longest
string that is inserted.
Member of : CExploreMsgSg
Author(s) : Robin G.K.
Date Created : 27.10.2015
Requirement ID : RS_FLX_08_09_10
***************************************************************************************/
void CExploreMsgSg::SetHorizExtentListBox(CListBox& omListBox)
{
// Set horizontal extent of the list
// box to max string availaable
// so that user can scroll
CSize sz;
CString omStrText;
CDC* pDC = omListBox.GetDC();
if ( pDC != nullptr)
{
int nDx = 0;
for (int nCount = 0;
nCount < omListBox.GetCount();
nCount++)
{
omListBox.GetText( nCount, omStrText );
// remove space
omStrText.TrimRight();
sz = pDC->GetTextExtent(omStrText);
if (sz.cx > nDx)
{
nDx = sz.cx;
}
}
omListBox.ReleaseDC(pDC);
// Set the horizontal extent so every character of all
// strings can be scrolled to.
omListBox.SetHorizontalExtent(nDx);
}
}
示例2: SetWidthByContentInListBox
void SetWidthByContentInListBox(CDialog* pDlg, int nID)
{
if (nID <= 0|| pDlg == NULL) return;
CWnd* pWnd = (CWnd*)pDlg;
CListBox* pCB = (CListBox*)pWnd->GetDlgItem(nID);
if (pCB == NULL) return;
int origSize = pCB->GetHorizontalExtent();
int maxSize = origSize;
CDC* pDC = pWnd->GetDC();
CString cStr;
int str_num = pCB->GetCount();
for (int i = 0; i < str_num; i++)
{
pCB->GetText(i, cStr);
CSize strSize = pDC->GetOutputTextExtent(cStr);
if (strSize.cx > maxSize)
maxSize = strSize.cx;
}
// in case when adding to list, existing items may be
// longer than newer ones, so may not want to resize
if (maxSize > origSize)
pCB->SetHorizontalExtent(maxSize);
}
示例3: AdjustHorzScroll
void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
{
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
int cxExtentMax = 0;
for (int i = 0; i < wndListBox.GetCount(); i ++)
{
CString strItem;
wndListBox.GetText(i, strItem);
//cxExtentMax = max(cxExtentMax, dc.GetTextExtent(strItem).cx);
// Just Ignore the min/max macro stuff
if (cxExtentMax >= dc.GetTextExtent(strItem).cx)
{
cxExtentMax = cxExtentMax;
}
else
{
cxExtentMax = dc.GetTextExtent(strItem).cx;
}
}
wndListBox.SetHorizontalExtent(cxExtentMax);
dc.SelectObject(pOldFont);
}
示例4: AdjustHorzScroll
void RateDocking::AdjustHorzScroll(CListBox& wndListBox)
{
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
int cxExtentMax = 0;
for (int i = 0; i < wndListBox.GetCount(); i ++)
{
CString strItem;
wndListBox.GetText(i, strItem);
cxExtentMax = max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx);
}
wndListBox.SetHorizontalExtent(cxExtentMax);
dc.SelectObject(pOldFont);
}
示例5: AdjustHorzScroll
void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
{
CClientDC dc(this);
CFont* pOldFont = dc.SelectObject(&m_Font);
int cxExtentMax = 0;
for (int i = 0; i < wndListBox.GetCount(); i ++)
{
CString strItem;
wndListBox.GetText(i, strItem);
cxExtentMax = bk::max(cxExtentMax, (int)dc.GetTextExtent(strItem).cx);
}
wndListBox.SetHorizontalExtent(cxExtentMax);
dc.SelectObject(pOldFont);
}