本文整理汇总了C++中CComboBox::SetItemHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ CComboBox::SetItemHeight方法的具体用法?C++ CComboBox::SetItemHeight怎么用?C++ CComboBox::SetItemHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComboBox
的用法示例。
在下文中一共展示了CComboBox::SetItemHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowInPlaceComboBox
CComboBox* CSHListCtrl::ShowInPlaceComboBox(int nItem, int nSubitem,DWORD dwStyle)
{
// The returned pointer should not be saved
// Make sure that the item is visible
// My code start here
if (!EnsureVisible(nItem, TRUE) )
return NULL;
// Make sure that nCol is valid
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
if( nSubitem >= nColumnCount || GetColumnWidth(nSubitem) < 10 )
return NULL;
// Get the column offset
int offset = 0;
for(int i = 0; i < nSubitem; i++)
offset += GetColumnWidth(i);
CRect rect;
GetItemRect(nItem, &rect, LVIR_BOUNDS);
// Now scroll if we need to expose the column
CRect rcClient;
GetClientRect(&rcClient);
if(offset + rect.left < 0 || offset + rect.left > rcClient.right)
{
CSize size;
size.cx = offset + rect.left;
size.cy = 0;
Scroll(size);
rect.left -= size.cx;
}
rect.left += offset;
rect.right = rect.left + GetColumnWidth( nSubitem ) ;
int height = rect.bottom - rect.top;
rect.bottom += 22 * height;
if (rect.right > rcClient.right)
rect.right = rcClient.right;
dwStyle |= WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DISABLENOSCROLL;
CComboBox* pList = new CSHInPlaceComboBox(nItem, nSubitem);
pList->Create(dwStyle, rect, this, IDC_INPLACE_COMBOBOX);
pList->SetItemHeight(-1, height);
pList->SetHorizontalExtent(GetColumnWidth(nSubitem));
CString strWindowText = GetItemText(nItem, nSubitem);
if(dwStyle & CBS_DROPDOWN && !(dwStyle & CBS_DROPDOWNLIST))
{
CEdit* m_pEdit = new CEdit();
m_pEdit->SubclassWindow(pList->GetDlgItem(1001)->GetSafeHwnd());
m_pEdit->SetWindowText(strWindowText);
m_pEdit->SetSel(0,-1);
}
return pList;
// My code end here
}