void CSkinListBox::OnRButtonUp(UINT nFlags, CPoint point) { CRect rcItem(0,0,0,0); SetSel(-1,FALSE); for (int i =0; i<GetCount(); i++) { GetItemRect(i, &rcItem); if(rcItem.PtInRect(point)) { if( IsSingleSel() ) SetCurSel(i); else SetSel(i); break; } } CWnd *pWnd = GetParent(); if ( (pWnd == NULL) && (pWnd->GetSafeHwnd() != NULL) ) return; pWnd->PostMessage(WM_COMMAND,GetDlgCtrlID(),0); Invalidate(FALSE); __super::OnRButtonUp(nFlags, point); }
void SListBoxEx::OnPaint(IRenderTarget * pRT) { SPainter duiDC; BeforePaint(pRT,duiDC); CRect rcClient; GetClientRect(&rcClient); pRT->PushClipRect(&rcClient,RGN_AND); int iFirstVisible=m_ptOrigin.y/m_nItemHei; int nPageItems=(m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; CRect rcClip,rcInter; pRT->GetClipBox(&rcClip); for(int iItem = iFirstVisible; iItem<GetItemCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); rcInter.IntersectRect(&rcClip,&rcItem); if(!rcInter.IsRectEmpty()) DrawItem(pRT,rcItem,iItem); } pRT->PopClip(); AfterPaint(pRT,duiDC); }
void CDuiListBox::RedrawItem(int iItem) { if(!IsVisible(TRUE)) return; CRect rcClient; GetClient(&rcClient); int iFirstVisible = GetTopIndex(); int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems) { CRect rcItem(0,0,rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(rcClient.TopLeft()); CDCHandle dc=GetDuiDC(&rcItem,OLEDC_PAINTBKGND); DuiDCPaint duiDC; BeforePaint(dc,duiDC); DuiSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)dc); DrawItem(dc,rcItem,iItem); AfterPaint(dc,duiDC); ReleaseDuiDC(dc); } }
void CXTPTaskPanelGroup::RepositionScrollOffset() { int nItemCount = GetItemCount(); int nLastVisibleItem = m_pItems->GetNextVisibleIndex(nItemCount, -1); int nScrollOffset = min(GetOffsetItem(), nLastVisibleItem); if (nScrollOffset > 0) { CRect rcItem(GetAt(nLastVisibleItem)->GetItemRect()); int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top; while ((nScrollOffset > 0) && ((rcItem.bottom - GetAt(nScrollOffset - 1)->GetItemRect().top + nTopMargin < m_nExpandedClientHeight) || !GetAt(nScrollOffset - 1)->IsVisible())) { nScrollOffset--; } } SetOffsetItem(nScrollOffset, FALSE); for (int i = 0; i < nItemCount; i++) { CXTPTaskPanelGroupItem* pItem = GetAt(i); if (pItem->IsItemFocused() || (pItem->IsItemSelected() && GetTaskPanel()->m_bSelectItemOnFocus)) { EnsureVisible(pItem, FALSE); break; } } }
DWORD CDuiHeaderCtrl::HitTest( CPoint pt ) { CRect rcClient; GetClient(&rcClient); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); int nMargin=m_bSortHeader?CX_HDITEM_MARGIN:0; for(int i=0;i<m_arrItems.GetCount();i++) { if(m_arrItems[i].cx==0) continue; //越过宽度为0的项 rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[i].cx; if(pt.x<rcItem.left+nMargin) { int nLeft=i>0?i-1:0; return MAKELONG(nLeft,i); }else if(pt.x<rcItem.right-nMargin) { return MAKELONG(i,i); }else if(pt.x<rcItem.right) { WORD nRight=(WORD)i+1; if(nRight>=m_arrItems.GetCount()) nRight=-1;//采用-1代表末尾 return MAKELONG(i,nRight); } } return -1; }
void CDuiHeaderCtrl::DrawDraggingState(DWORD dwDragTo) { CRect rcClient; GetClient(&rcClient); CDCHandle dc=GetDuiDC(rcClient,OLEDC_PAINTBKGND); DuiDCPaint duidc; BeforePaint(dc,duidc); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); int iDragTo=LOWORD(dwDragTo); int iDragFrom=LOWORD(m_dwHitTest); CDuiArray<int> items; for(int i=0;i<m_arrItems.GetCount();i++) { if(i!=iDragFrom) items.Add(i); } items.InsertAt(iDragTo,iDragFrom); m_pSkinItem->Draw(dc,rcClient,0); for(int i=0;i<items.GetCount();i++) { rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[items[i]].cx; if(items[i]!=iDragFrom) DrawItem(dc,rcItem,m_arrItems.GetData()+items[i]); } AfterPaint(dc,duidc); ReleaseDuiDC(dc); }
void CHoverButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your code to draw the specified item CDC *pDC=CDC::FromHandle(lpDrawItemStruct->hDC); CPoint point(0,0); CGumpPtr pDib = m_pDib[NORMAL]; UINT state = lpDrawItemStruct->itemState; if (!IsCheckbox()) { if (state & ODS_DISABLED) pDib = m_pDib[NORMAL]; else if (state & ODS_SELECTED) pDib = m_pDib[PRESSED]; else if (m_bHover) pDib = m_pDib[HOVER]; } else { if (m_bClick) pDib = m_pDib[PRESSED]; } if (pDib) pDib->DrawTransparent(pDC, CPoint(0,0), RGB(255,255,255)); CString strText; GetWindowText(strText); CRect rcItem(lpDrawItemStruct->rcItem); if (lpDrawItemStruct->itemState & ODS_SELECTED) rcItem += CPoint(2,2); SetTextColor(lpDrawItemStruct->hDC, m_bHover ? RGB(255,255,0) : RGB(255,255,255)); DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), &rcItem, DT_CENTER | DT_VCENTER | DT_SINGLELINE); }
void CXTPReportRecordItemPreview::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics) { ASSERT(pDrawArgs->pControl); if (!pDrawArgs->pControl) return; if (!pDrawArgs->pControl->GetPaintManager()->OnDrawAction(pDrawArgs)) return; CString strText = pMetrics->strText; // draw item text if (!strText.IsEmpty()) { CRect rcItem(pDrawArgs->rcItem); CRect& rcIndent = pDrawArgs->pControl->GetPaintManager()->m_rcPreviewIndent; rcItem.DeflateRect(rcIndent.left, rcIndent.top, rcIndent.right, rcIndent.bottom); if (m_pMarkupUIElement) { XTPMarkupSetDefaultFont(XTPMarkupElementContext(m_pMarkupUIElement), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground); XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX); XTPMarkupRenderElement(m_pMarkupUIElement, pDrawArgs->pDC->GetSafeHdc(), &rcItem); } else { pDrawArgs->pDC->DrawText(strText, rcItem, DT_WORDBREAK | DT_LEFT | DT_NOPREFIX); } } }
void CSkinListBox::OnMouseMove(UINT nFlags, CPoint point) { if (!m_bMouseTracking) { TrackMouseLeave(GetSafeHwnd()); m_bMouseTracking = TRUE; Invalidate(FALSE); } CRect rcItem(0,0,0,0); //保存旧状态,为了防止在同一个节点下因过多的刷新消耗cpu资源 static int nOldIndex = -1; for (int i =0; i<GetCount(); i++) { GetItemRect(i, &rcItem); if(rcItem.PtInRect(point)) { if( m_nHovenItem != i ) Invalidate(FALSE); m_nHovenItem = i; break; } } __super::OnMouseMove(nFlags, point); }
//光标消息 BOOL CControlWnd::OnSetCursor(CWnd * pWnd, UINT nHitTest, UINT uMessage) { //位置测试 if (m_cbItemCount!=0) { //获取位置 CRect rcClient; CPoint MousePoint; GetClientRect(&rcClient); GetCursorPos(&MousePoint); ScreenToClient(&MousePoint); //计算索引 BYTE bCurrentItem=0xFF; CRect rcItem(5,5,rcClient.Width()-5,ITEM_HEIGHT*m_cbItemCount+5); if (rcItem.PtInRect(MousePoint)) bCurrentItem=(BYTE)((MousePoint.y-7)/ITEM_HEIGHT); //设置索引 if (m_cbCurrentItem!=bCurrentItem) { Invalidate(FALSE); m_cbCurrentItem=bCurrentItem; } //设置光标 if (m_cbCurrentItem!=0xFF) { SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CARD_CUR))); return TRUE; } } return __super::OnSetCursor(pWnd,nHitTest,uMessage); }
void CXTPHeaderCtrlThemeExplorer::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS) { CRect rcItem(lpDIS->rcItem); CDC* pDC = CDC::FromHandle(lpDIS->hDC); // fill background pDC->FillSolidRect(&rcItem, m_cr3DFace); rcItem.right += 2; // draw 3D borders. pDC->Draw3dRect(&rcItem, m_cr3DHighLight, m_cr3DShadow); }
CRect CDuiHeaderCtrl::GetItemRect( int iItem ) { CRect rcClient; GetClient(&rcClient); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); for(int i=0;i<=iItem && i<m_arrItems.GetCount();i++) { rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[i].cx; } return rcItem; }
CRect CXTPControlScrollBar::GetScrollBarRect() { CRect rcItem(GetRect()); rcItem.DeflateRect(2, 2, 2, 2); if (m_pParent->GetType() == xtpBarTypePopup && m_pParent->GetPosition() == xtpBarPopup) { CXTPPaintManager* pPaintManager = GetPaintManager(); rcItem.left += pPaintManager->GetPopupBarGripperWidth(GetParent()) + pPaintManager->m_nPopupBarTextPadding - 2; } return rcItem; }
BOOL CXTPTaskPanelGroup::IsScrollButtonEnabled(BOOL bScrollButtonUp) const { CXTPTaskPanelGroupItem* pLastVisibleItem = (CXTPTaskPanelGroupItem*)m_pItems->GetLastVisibleItem(); if (pLastVisibleItem == NULL) return FALSE; if (bScrollButtonUp) return m_nScrollOffset != 0; CRect rcItem(pLastVisibleItem->GetItemRect()); return rcItem.bottom - GetScrollOffsetPos() > m_rcGroupTarget.Height() - m_nCaptionHeight; }
HBITMAP CDuiHeaderCtrl::CreateDragImage( int iItem ) { if(iItem<0 || iItem>=m_arrItems.GetCount()) return NULL; CRect rcClient; GetClient(rcClient); CRect rcItem(0,0,m_arrItems[iItem].cx,rcClient.Height()); CDCHandle dc=GetDuiDC(NULL,OLEDC_NODRAW); CMemDC memdc(dc,rcItem); CDCHandle hmemdc=memdc; BeforePaintEx(hmemdc); DrawItem(hmemdc,rcItem,m_arrItems.GetData()+iItem); HBITMAP hItemBmp=memdc.SelectBitmap(NULL); ReleaseDuiDC(dc); return hItemBmp; }
void KDlg_PropertyDialog::RecalcLayout() { if(!::IsWindow(m_hWnd)) return ; /*CWnd *pParent = GetParent(); if(pParent == NULL) //必须有父窗口 return ;*/ CRect rcRect; m_Tab.GetWindowRect(rcRect); //pParent->ScreenToClient(&rcRect); int nRow = m_Tab.GetRowCount(); CRect rcItem(0, 0, 0, 0); m_Tab.GetItemRect(0, &rcItem); CPoint pt = CPoint(0, 0); int K = nRow*(rcItem.Height() + 3); pt.Offset(3, K); for(DWORD i=0;i<m_vecPage.size();i++) { CRect rcMove; m_vecPage[i]->GetWindowRect(rcMove); CPoint Move; Move.x = rcRect.left - rcMove.left + pt.x; Move.y = rcRect.top - rcMove.top + pt.y; rcMove.OffsetRect(Move); rcMove.right = rcMove.left + rcRect.Width() - 3; rcMove.bottom = rcMove.top + rcRect.Height() - K - 3; m_vecPage[i]->MoveWindow(rcMove); if(rcRect.right < rcMove.right) rcRect.right = rcMove.right; if(rcRect.bottom < rcMove.bottom) rcRect.bottom = rcMove.bottom; } //MoveWindow(rcRect); }
void paint(QPainter* p) { int w = listBox()->maxItemWidth(); if (w < listBox()->width()) w = listBox()->width(); int h = height(listBox()); QRect rcItem(0, 0, w, h); p->setBackgroundColor(listBox()->colorGroup().background()); p->eraseRect(rcItem); qDrawShadeLine(p, 4, h / 2, w - 8, h / 2, listBox()->colorGroup(), false, 1, 0); p->setBackgroundMode(Qt::OpaqueMode); p->setPen(listBox()->colorGroup().buttonText()); p->drawText(4, 0, 102, h, Qt::AlignCenter | Qt::AlignVCenter, " " + text() + " "); }
void Slider::HandleVertical(int pos) { suic::Rect rcItem(0, 0, RenderSize().cx, RenderSize().cy); const suic::Size& thumbSize = _thumbBtn->GetDesiredSize(); if (pos <= rcItem.top ) { SetValue(Minimum()); } else if (pos >= rcItem.bottom - thumbSize.cy) { SetValue(Maximum()); } else { SetValue(Minimum() + (Maximum() - Minimum()) * (double)(pos) / (double)(rcItem.Height() - thumbSize.cy)); } }
void SListBox::OnPaint(IRenderTarget * pRT) { SPainter painter; BeforePaint(pRT,painter); int iFirstVisible = GetTopIndex(); int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); DrawItem(pRT,rcItem,iItem); } AfterPaint(pRT,painter); }
void Slider::HandleHorizontal(int pos) { suic::Rect rcItem(0, 0, RenderSize().cx, RenderSize().cy); const suic::Size& thumbSize = _thumbBtn->GetDesiredSize(); if (pos >= rcItem.right - thumbSize.cx) { SetValue(Maximum()); } else if (pos <= rcItem.left) { SetValue(Minimum()); } else { SetValue(Minimum() + (Maximum() - Minimum()) * (double)(pos) / (double)(rcItem.Width() - thumbSize.cx)); } }
void CDuiListBox::OnPaint(CDCHandle dc) { DuiDCPaint duiDC; BeforePaint(dc,duiDC); int iFirstVisible = GetTopIndex(); int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); DrawItem(dc,rcItem,iItem); } AfterPaint(dc,duiDC); }
void CXTPHeaderCtrlThemeOffice2003::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS) { CRect rcItem(lpDIS->rcItem); CDC* pDC = CDC::FromHandle(lpDIS->hDC); // fill background pDC->FillSolidRect(&rcItem, m_cr3DFace); rcItem.right += 2; // draw 3D borders. pDC->Draw3dRect(&rcItem, m_cr3DHighLight, MixColor(m_cr3DFace, m_cr3DShadow, 0.6)); CXTPPenDC penDC(lpDIS->hDC, MixColor(m_cr3DFace, m_cr3DShadow, 0.4)); pDC->MoveTo(rcItem.left, rcItem.bottom-2); pDC->LineTo(rcItem.right, rcItem.bottom-2); penDC.Color(MixColor(m_cr3DFace, m_cr3DShadow, 0.25)); pDC->MoveTo(rcItem.left, rcItem.bottom-3); pDC->LineTo(rcItem.right, rcItem.bottom-3); }
void CXTPTaskPanelGroup::EnsureVisible(CXTPTaskPanelGroupItem* pItem, BOOL bUpdateScrollButtons /*= TRUE*/) { if (m_pPanel->IsExplorerBehaviour() || GetItemCount() == 0 || !IsExpanded()) return; if (!pItem || pItem->GetItemGroup() != this || !pItem->IsVisible()) return; int nIndex = pItem->GetIndex(); if (m_nScrollOffset > nIndex) { SetOffsetItem(nIndex, bUpdateScrollButtons); return; } CRect rcItem(pItem->GetItemRect()); if (rcItem.bottom - GetScrollOffsetPos() > m_nExpandedClientHeight) { int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top; if (rcItem.top - GetScrollOffsetPos() <= nTopMargin) return; int nScrollOffset = m_nScrollOffset + 1; for (; nScrollOffset <= nIndex; nScrollOffset++) { CXTPTaskPanelGroupItem* pItemScroll = GetAt(nScrollOffset); if (!pItemScroll || !pItemScroll->IsVisible()) continue; int nScrollOffsetPos = pItemScroll->GetItemRect().top - nTopMargin; if (rcItem.bottom - nScrollOffsetPos <= m_nExpandedClientHeight) break; if (rcItem.top - nScrollOffsetPos <= nTopMargin) break; } SetOffsetItem(nScrollOffset, bUpdateScrollButtons); } }
void CTSKTabManager::RepositionTabControl(CTSKTabManager* pTabManager, CDC* pDC, CRect rcClient) { CRect rc(rcClient); CRect rcItem(rc.left, rc.top, rc.left, rc.bottom); int nWidth = /*rcClient.Width() / pTabManager->GetItemCount()*/20; if (nWidth < m_nMinWidth) nWidth = m_nMinWidth; for (int i = 0; i < pTabManager->GetItemCount(); i++) { CTSKTabManagerItem* pItem = pTabManager->GetItem(i); rcItem.right = rcItem.left + nWidth; pItem->SetRect(rcItem); rcItem.left += nWidth; } }
// CTwoListCtrl 消息处理程序 void CSkinListProgressCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS ) { // TODO: Add your message handler code here and/or call default CDC *pDC = CDC::FromHandle(lpDIS->hDC); int nRows = m_lstItemColor.GetCount(); COLORREF *clrCol = NULL; if (nRows && (int)lpDIS->itemID < nRows) { clrCol = m_lstItemColor.GetAt(m_lstItemColor.FindIndex(lpDIS->itemID)); } CRect rcItem(lpDIS->rcItem); LVCOLUMN lvColumn; ZeroMemory(&lvColumn, sizeof(LVCOLUMN)); lvColumn.mask = LVCF_FMT | LVCF_WIDTH; for (int nCol = 0; nCol < GetHeaderCtrl()->GetItemCount(); nCol++) { if (clrCol) { pDC->SetBkColor(clrCol[nCol]); pDC->SetTextColor(clrCol[nCol]); } GetColumn(nCol, &lvColumn); UINT uStyle = DT_SINGLELINE | DT_END_ELLIPSIS; if (lvColumn.fmt & LVCFMT_LEFT) uStyle |= DT_LEFT; if (lvColumn.fmt & LVCFMT_RIGHT) uStyle |= DT_RIGHT; if (lvColumn.fmt & LVCFMT_CENTER) uStyle |= DT_CENTER; rcItem.right = rcItem.left + lvColumn.cx; // COLORREF color; // GetSysColor(color); // pDC->FillSolidRect(rcItem, RGB(122,122,122));//::GetSysColor(COLOR_INACTIVECAPTION)); pDC->FillSolidRect(rcItem, m_listItemColor1); pDC->DrawText(GetItemText(lpDIS->itemID, nCol), rcItem, uStyle); rcItem.left += lvColumn.cx; } // CListCtrl::OnDrawItem(nIDCtl, lpDIS); }
void CSkinComboBox_ListBox::OnRButtonUp(UINT nFlags, CPoint point) { CRect rcItem(0,0,0,0); int nIndex = -1; for (int i =0; i<GetCount(); i++) { GetItemRect(i, &rcItem); if(rcItem.PtInRect(point)) { if ( m_hOwnerWnd != NULL ) nIndex = i; break; } } ::PostMessage(m_hOwnerWnd,WM_CBO_LIST_RBUTTONUP,nIndex,0); __super::OnRButtonUp(nFlags, point); }
void SListBox::RedrawItem(int iItem) { if(!IsVisible(TRUE)) return; CRect rcClient; GetClientRect(&rcClient); int iFirstVisible = GetTopIndex(); int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems) { CRect rcItem(0,0,rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(rcClient.TopLeft()); IRenderTarget *pRT=GetRenderTarget(&rcItem,OLEDC_PAINTBKGND); SSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)pRT); DrawItem(pRT,rcItem,iItem); ReleaseRenderTarget(pRT); } }
void CDuiHeaderCtrl::OnPaint( CDCHandle dc ) { DuiDCPaint duiDC; BeforePaint(dc,duiDC); CRect rcClient; GetClient(&rcClient); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); for(int i=0;i<m_arrItems.GetCount();i++) { rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[i].cx; DrawItem(dc,rcItem,m_arrItems.GetData()+i); if(rcItem.right>=rcClient.right) break; } if(rcItem.right<rcClient.right) { rcItem.left=rcItem.right; rcItem.right=rcClient.right; m_pSkinItem->Draw(dc,rcItem,0); } AfterPaint(dc,duiDC); }
BOOL CXTPTaskPanelGroup::IsItemVisible(CXTPTaskPanelGroupItem* pItem, BOOL bAllowPart) const { if (!IsExpanded()) return FALSE; if (!pItem || pItem->GetItemGroup() != this || !pItem->IsVisible()) return FALSE; if (m_pPanel->IsExplorerBehaviour()) return TRUE; int nIndex = pItem->GetIndex(); if (m_nScrollOffset > nIndex) return FALSE; CRect rcItem(pItem->GetItemRect()); if ((bAllowPart ? rcItem.top : rcItem.bottom) - GetScrollOffsetPos() > m_rcGroupTarget.Height() - m_nCaptionHeight) return FALSE; return TRUE; }
CRect CDuiItemBox::GetItemRect(int iItem) { CRect rcClient=m_rcWindow; int nPageCols=(rcClient.Width()+m_nSepWid)/(m_nItemWid+m_nSepWid); int nPageRows=(rcClient.Height()+m_nSepHei)/(m_nItemHei+m_nSepHei); if(nPageCols<1) nPageCols=1; int nPageItems=nPageCols*nPageRows; if(nPageItems<GetItemCount()) { rcClient.right-=m_nSbWid; nPageCols=(rcClient.Width()+m_nSepWid)/(m_nItemWid+m_nSepWid); if(nPageCols<1) nPageCols=1; nPageItems=nPageCols*nPageRows; } int nMargin=(rcClient.Width()-((m_nItemWid+m_nSepWid)*nPageCols-m_nSepWid))/2; CRect rcItem(CPoint(nMargin,0),CSize(m_nItemWid,m_nItemHei)); int iCol=iItem%nPageCols; int iRow=iItem/nPageCols; rcItem.OffsetRect(iCol*(m_nItemWid+m_nSepWid),iRow*(m_nItemHei+m_nSepHei)); return rcItem; }