当前位置: 首页>>代码示例>>C++>>正文


C++ CListBox::GetWindowRect方法代码示例

本文整理汇总了C++中CListBox::GetWindowRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CListBox::GetWindowRect方法的具体用法?C++ CListBox::GetWindowRect怎么用?C++ CListBox::GetWindowRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CListBox的用法示例。


在下文中一共展示了CListBox::GetWindowRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: substituteControl

void CListBoxDiffMarks::substituteControl(CWnd *parent, int id) {
  DEFINEMETHODNAME;
  CListBox *oldCtrl = (CListBox*)parent->GetDlgItem(id);
  if(oldCtrl == NULL) {
    showError(_T("%s:Control with id=%d does not exist"), method, id);
    return;
  }
  CRect wr;
  oldCtrl->GetWindowRect(&wr);
  parent->ScreenToClient(&wr);
  DWORD style   = oldCtrl->GetStyle();
  const DWORD exStyle = oldCtrl->GetExStyle();
  style |= LBS_OWNERDRAWFIXED | WS_BORDER;
  style &= ~(LBS_SORT);

  CFont *font = oldCtrl->GetFont();
  if(font == NULL) {
    font = parent->GetFont();
  }
  const CompactIntArray tabOrder = getTabOrder(parent);
  oldCtrl->DestroyWindow();

  if(!Create(style, wr, parent, id)) {
    showError(_T("%s:Create failed"), method);
    return;
  }
  setTabOrder(parent, tabOrder);
  ModifyStyleEx(0, exStyle);
  SetFont(font);
  m_charSize.cx = m_charSize.cy = 0;
  setEqualSelected(::GetSysColor(COLOR_HIGHLIGHTTEXT),::GetSysColor(COLOR_HIGHLIGHT   ));
  setDiffSelected( ::GetSysColor(COLOR_HIGHLIGHT    ),::GetSysColor(COLOR_HIGHLIGHTTEXT));
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:33,代码来源:ListBoxDiffMarks.cpp

示例2: ShowInPlaceListBox

CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel)
{
    CRect rect;
    if (!PrepareInPlaceControl(nItem, nCol, rect)) {
        return nullptr;
    }

    DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL/*|WS_HSCROLL*/ | LBS_NOTIFY;
    CListBox* pListBox = DEBUG_NEW CInPlaceListBox(nItem, nCol, lstItems, nSel);
    pListBox->Create(dwStyle, rect, this, IDC_LIST1);

    CRect ir;
    GetItemRect(m_nItemClicked, &ir, LVIR_BOUNDS);

    pListBox->SetItemHeight(-1, ir.Height());

    CDC* pDC = pListBox->GetDC();
    CFont* pWndFont = GetFont();
    pDC->SelectObject(pWndFont);
    int width = GetColumnWidth(nCol);
    POSITION pos = lstItems.GetHeadPosition();
    while (pos) {
        int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
        if (width < w) {
            width = w;
        }
    }
    ReleaseDC(pDC);

    CRect r;
    pListBox->GetWindowRect(r);
    ScreenToClient(r);
    r.top = ir.bottom;
    r.bottom = r.top + pListBox->GetItemHeight(0) * (pListBox->GetCount() + 1);
    r.right = r.left + width;
    pListBox->MoveWindow(r);

    m_fInPlaceDirty = false;

    return pListBox;
}
开发者ID:Chris-Hood,项目名称:mpc-hc,代码行数:41,代码来源:PlayerListCtrl.cpp


注:本文中的CListBox::GetWindowRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。