本文整理汇总了C++中CComboBox::ShowDropDown方法的典型用法代码示例。如果您正苦于以下问题:C++ CComboBox::ShowDropDown方法的具体用法?C++ CComboBox::ShowDropDown怎么用?C++ CComboBox::ShowDropDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComboBox
的用法示例。
在下文中一共展示了CComboBox::ShowDropDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowInPlaceComboBox
CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown)
{
CRect rect;
if (!PrepareInPlaceControl(nItem, nCol, rect)) {
return nullptr;
}
DWORD dwStyle = /*WS_BORDER|*/WS_CHILD | WS_VISIBLE | WS_VSCROLL /*|WS_HSCROLL*/
| CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL/*|CBS_NOINTEGRALHEIGHT*/;
CComboBox* pComboBox = DEBUG_NEW CInPlaceComboBox(nItem, nCol, lstItems, nSel);
pComboBox->Create(dwStyle, rect, this, IDC_COMBO1);
CorrectComboListWidth(*pComboBox);
int width = GetColumnWidth(nCol);
if (pComboBox->GetDroppedWidth() < width) {
pComboBox->SetDroppedWidth(width);
}
if (bShowDropDown) {
pComboBox->ShowDropDown();
}
m_fInPlaceDirty = false;
return pComboBox;
}
示例2: DoCompletion
void CAutoComplete::DoCompletion(CWnd* pWnd, CString s,
const CStringArray& arMatches)
{
if (m_iType==ComboBox)
{
// 这种强制转换从技术上讲是不正确的,但它是一个标准的MFC诀窍.
CComboBox* pComboBox = (CComboBox*)pWnd;
// 更新下拉框以反映可能的匹配
pComboBox->ResetContent();
for (int i=0; i <arMatches.GetSize();i++)
pComboBox->AddString(arMatches[i]);
// 用户箭头光标,这样用户才能选择
::SetCursor(LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW)));
// 显示下拉框
pComboBox->ShowDropDown();
pComboBox->SetWindowText(IgnoreCompletion(s) ? s : arMatches[0]);
pComboBox->SetEditSel(s.GetLength(),-1); //设置高亮
}
else if (m_iType==Edit && !IgnoreCompletion(s))
{
// 这种强制转换从技术上讲是不正确的,但它是一个标准的MFC诀窍.
CEdit* pEdit = (CEdit*)pWnd;
pEdit->SetWindowText(arMatches[0]);
pEdit->SetSel(s.GetLength(),-1);
}
}
示例3: ShowList
CComboBox* CMySuperGrid::ShowList(int nItem, int nCol, CStringList *lstItems)
{
CString strFind = GetItemText(nItem, nCol);
//basic code start
CRect rect;
int offset = 0;
// Make sure that the item is visible
if( !EnsureVisible(nItem, TRUE)) return NULL;
GetSubItemRect(nItem, nCol, LVIR_BOUNDS, rect);
// 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(nCol);
if(rect.right > rcClient.right)
rect.right = rcClient.right;
//basic code end
rect.bottom += 10 * rect.Height();//dropdown area
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL|CBS_DROPDOWNLIST | CBS_DISABLENOSCROLL;
CComboBox *pList = new CComboInListView(nItem, nCol, lstItems);
pList->Create(dwStyle, rect, this, IDC_COMBOBOXINLISTVIEW);
pList->ModifyStyleEx(0,WS_EX_CLIENTEDGE);//can we tell at all
pList->SetHorizontalExtent(CalcHorzExtent(pList, lstItems));
pList->ShowDropDown();
pList->SelectString(-1, strFind.GetBuffer(1));
// The returned pointer should not be saved
return pList;
}