예제 #1
0
void CTreeWnd::DeleteAllNodes()
{
	if (!m_pTree)
		return;

    m_selection.Clear();

	// clear all nodes
	mtNode* pRoot = m_pTree->getRoot();
    if (pRoot)
    {
        DeleteNode(pRoot);
        CTreeNode* pTN = (CTreeNode*)pRoot->getData2();
        delete pTN;
    }
    m_pTree->removeAll();
    m_firstVisible = NULL;

	SetScrollPos32(SB_VERT,0);
	SetScrollPos32(SB_HORZ,0);


    ForceLayout();
    Invalidate();
}
예제 #2
0
void CGraphListCtrl::OnSetCurSel( int nItem, bool bMsg )
{
	if (!m_bAllowSel)
	{
		return;
	}

	m_nCurSel = nItem;
	if (-1 != m_nCurSel)
	{
		int nVertScroll = GetScrollPos(SB_VERT), 
			nHorzScroll = GetScrollPos(SB_HORZ);

		CRect rt = GetItemRect(m_nCurSel);
		rt.OffsetRect(-nHorzScroll, -nVertScroll);
		CRect rtClient;
		GetClientRect(rtClient);
		if( !rtClient.PtInRect( CPoint(rt.left + rt.Width() / 2,
			rt.top  + rt.Height() / 2) ) )
		{
			if((rtClient.left > rt.left) || (rtClient.right < rt.right) )
			{
				rt.OffsetRect(nHorzScroll, nVertScroll);
				SetScrollPos32(SB_HORZ, rt.left);
			} else if((rtClient.top > rt.top) || (rtClient.bottom < rt.bottom) )
			{
				rt.OffsetRect(nHorzScroll, nVertScroll);
				SetScrollPos32(SB_VERT, rt.top);
			} else
			{
				rt.OffsetRect(nHorzScroll, nVertScroll);
				SetScrollPos32(SB_HORZ, rt.left);
				SetScrollPos32(SB_VERT, rt.top);
			}
		}
	}

	Invalidate();
	if (bMsg)
	{
		SendCommandToParent(LBN_SELCHANGE);
	}
}
예제 #3
0
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();
}
예제 #4
0
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();
}
예제 #5
0
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();
}
예제 #6
0
/***
	响应垂直滚动条消息
*/
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;
	}
}