void CTreeWnd::SetFirstVisibleNode() { m_firstVisibleIdx = 0; int index = GetScrollPos32(SB_VERT); CTreeNode* pNode = GetRootNode(); if (!pNode) return; if (!(m_style & MTS_SHOWROOT)) pNode = pNode->FirstChild(); m_firstVisible = pNode; int pos = 0; while (pNode && pos < index) { pos ++;//= DEF_NODE_HEIGHT; pNode = pNode->NextNode(); if (pNode) { m_firstVisible = pNode; m_firstVisibleIdx++; } } }
void CCurveButton::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC * pDC = GetDC(); if( NULL == pDC ) return; CRect rectClient; GetClientRect( &rectClient ); pDC->FillSolidRect( rectClient, AfxGetProfile().GetColor(CColorClass::clrGraphBK) ); int scrollpos = GetScrollPos32( SB_HORZ ); DrawCurve( pDC, rectClient, scrollpos ); }
int CGraphListCtrl::GetMinVisibleItem() { CSize sizeItem = GetItemSizeWithCaption(); if (!m_bSortByFixedRow) { int nVertScroll = GetScrollPos32(SB_VERT); int nRow = nVertScroll / sizeItem.cy; return nRow * m_nFixedColNum; } else { int nHorzScroll = GetScrollPos(SB_HORZ); int nCol = nHorzScroll / sizeItem.cx; return nCol * m_nFixedRowNum; } }
void CGraphListCtrl::OnScroll( UINT nFlags, short zDelta ) { int nBar = m_bSortByFixedRow ? SB_HORZ : SB_VERT; int nMaxPos = m_bSortByFixedRow ? m_nHScrollMax : m_nVScrollMax; int nMinPos = 0; int nScrolPos = GetScrollPos32(nBar); nScrolPos -= zDelta; if (0 > nScrolPos) nScrolPos = 0; else if (nMaxPos < nScrolPos) nScrolPos = nMaxPos; SetScrollPos32(nBar, nScrolPos, TRUE); Invalidate(); }
void CGraphListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int scrollPos = GetScrollPos32(SB_VERT); CSize size = GetItemSizeWithCaption(); CRect rt; GetClientRect(rt); int nPageHeight = rt.Height() - rt.Height() % size.cy; if (rt.Height() < size.cy) { nPageHeight = size.cy; } switch (nSBCode) { case SB_LINEDOWN: if (scrollPos < m_nVScrollMax) { int yScroll = size.cy; SetScrollPos32(SB_VERT, scrollPos + yScroll); if (GetScrollPos32(SB_VERT) == scrollPos) { break; // didn't work } } break; case SB_LINEUP: { int yScroll = size.cy; SetScrollPos32(SB_VERT, max(0, scrollPos - yScroll)); //RedrawWindow(NULL, NULL, RDW_ RDW_FRAME); } break; case SB_PAGEDOWN: if (scrollPos < m_nVScrollMax) { scrollPos = min(m_nVScrollMax, scrollPos + size.cy); SetScrollPos32(SB_VERT, scrollPos); } break; case SB_PAGEUP: if (scrollPos > 0) { scrollPos = max(0, scrollPos - size.cy); SetScrollPos32(SB_VERT, scrollPos); } break; case SB_THUMBPOSITION: case SB_THUMBTRACK: { SetScrollPos32(SB_VERT, GetScrollPos32(SB_VERT, TRUE)); } break; case SB_TOP: if (scrollPos > 0) { SetScrollPos32(SB_VERT, 0); } break; case SB_BOTTOM: if (scrollPos < m_nVScrollMax) { SetScrollPos32(SB_VERT, m_nVScrollMax); } default: break; } Invalidate(); }
void CGraphListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int scrollPos = GetScrollPos32(SB_HORZ); CSize size = GetItemSizeWithCaption(); CRect rt; GetClientRect(rt); int nPageWid = rt.Width() - (rt.Width() % size.cx); if (rt.Width() < size.cx) { nPageWid = size.cx; } // mod by yanghailong.2010.08.30 // 对图片来说,显示半张是没有意义的。 switch (nSBCode) { case SB_LINERIGHT: if (scrollPos < m_nHScrollMax) { int xScroll = size.cx; SetScrollPos32(SB_HORZ, scrollPos + xScroll); if (GetScrollPos32(SB_HORZ) == scrollPos) break; // didn't work } break; case SB_LINELEFT: SetScrollPos32(SB_HORZ, max(0, scrollPos - size.cx)); break; case SB_PAGERIGHT: if (scrollPos < m_nHScrollMax) { int pos = min(m_nHScrollMax, scrollPos + nPageWid); SetScrollPos32(SB_HORZ, pos); } break; case SB_PAGELEFT: if (scrollPos > 0) { int pos = max(0, scrollPos - nPageWid); SetScrollPos32(SB_HORZ, pos); } break; case SB_THUMBPOSITION: case SB_THUMBTRACK: { SetScrollPos32(SB_HORZ, nPos); } break; case SB_LEFT: if (scrollPos > 0) { SetScrollPos32(SB_HORZ, 0); } break; case SB_RIGHT: if (scrollPos < m_nHScrollMax) { SetScrollPos32(SB_HORZ, m_nHScrollMax); } break; default: break; } Invalidate(); }
int CGraphListCtrl::GetTopRowNum() { int nVertScroll = GetScrollPos32(SB_VERT); CSize size = GetItemSizeWithCaption(); return nVertScroll / size.cy; }
int CGraphListCtrl::GetTopColumnNum() { int nHorzScroll = GetScrollPos32(SB_HORZ); CSize size = GetItemSizeWithCaption(); return nHorzScroll / size.cx; }
/*** 响应垂直滚动条消息 */ void CCurveButton::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { int scrollPos = GetScrollPos32(SB_HORZ); switch (nSBCode) { case SB_LINERIGHT: if( scrollPos < m_nHScrollMax ) { SetScrollPos32(SB_HORZ, scrollPos + 1); if( GetScrollPos32(SB_HORZ) != scrollPos ) Invalidate( ); } break; case SB_LINELEFT: if( scrollPos > 0 ) { SetScrollPos32(SB_HORZ, max(0,scrollPos - 1)); Invalidate( ); } break; case SB_PAGERIGHT: if( scrollPos < m_nHScrollMax ) { int pos = min(m_nHScrollMax, scrollPos + GetScrollPage(SB_HORZ)); SetScrollPos32( SB_HORZ, pos); Invalidate( ); } break; case SB_PAGELEFT: if (scrollPos > 0) { int pos = max(0, scrollPos - GetScrollPage(SB_HORZ)); SetScrollPos32(SB_HORZ, pos); Invalidate( ); } break; case SB_THUMBPOSITION: case SB_THUMBTRACK: { SetScrollPos32(SB_HORZ, GetScrollPos32(SB_HORZ, TRUE)); Invalidate( ); } break; case SB_LEFT: if (scrollPos > 0) { SetScrollPos32(SB_HORZ, 0); Invalidate(); } break; case SB_RIGHT: if (scrollPos < m_nHScrollMax) { SetScrollPos32(SB_HORZ, m_nHScrollMax); Invalidate(); } break; default: break; } }