Beispiel #1
0
void CContainerUI::Event(TEventUI& event)
{
   if( m_hwndScroll != NULL ) 
   {
      if( event.Type == UIEVENT_VSCROLL ) 
      {
         switch( LOWORD(event.wParam) ) {
         case SB_THUMBPOSITION:
         case SB_THUMBTRACK:
            {
               SCROLLINFO si = { 0 };
               si.cbSize = sizeof(SCROLLINFO);
               si.fMask = SIF_TRACKPOS;
               ::GetScrollInfo(m_hwndScroll, SB_CTL, &si);
               SetScrollPos(si.nTrackPos);
            }
            break;
         case SB_LINEUP:
            SetScrollPos(GetScrollPos() - 5);
            break;
         case SB_LINEDOWN:
            SetScrollPos(GetScrollPos() + 5);
            break;
         case SB_PAGEUP:
            SetScrollPos(GetScrollPos() - GetScrollPage());
            break;
         case SB_PAGEDOWN:
            SetScrollPos(GetScrollPos() + GetScrollPage());
            break;
         }
      }
      if( event.Type == UIEVENT_KEYDOWN ) 
      {
         switch( event.chKey ) {
         case VK_DOWN:
            SetScrollPos(GetScrollPos() + 5);
            return;
         case VK_UP:
            SetScrollPos(GetScrollPos() - 5);
            return;
         case VK_NEXT:
            SetScrollPos(GetScrollPos() + GetScrollPage());
            return;
         case VK_PRIOR:
            SetScrollPos(GetScrollPos() - GetScrollPage());
            return;
         case VK_HOME:
            SetScrollPos(0);
            return;
         case VK_END:
            SetScrollPos(9999);
            return;
         }
      }
   }
   CControlUI::Event(event);
}
Beispiel #2
0
void CDocWindow::ResetScrollPos(int nBar, int nPos, bool bRedraw)
{
	int nMin = 0;
	int nMax = 0;
	GetScrollRange(nBar, &nMin, &nMax);
	if (nPos < nMin)
		nPos = nMin;
	int nPage = GetScrollPage(nBar);
	if (nPos > nMax + 1 - nPage)
		nPos = nMax + 1 - nPage;
	SetScrollPos(nBar, nPos, bRedraw);
}
Beispiel #3
0
void CDocWindow::SetupScrollbars(int xPos, int yPos, int xSize, int ySize, int xVisible, int yVisible, bool bRedraw)
{
	// If no (x,y) position was passed in, set the position to be the center of the current page
	if (xPos < 0 && yPos < 0)
	{
		xPos = GetScrollPos(SB_HORZ) + GetScrollPage(SB_HORZ)/2 - xVisible/2;
		yPos = GetScrollPos(SB_VERT) + GetScrollPage(SB_VERT)/2 - yVisible/2;
	}

	// Set the scroll range
	SetScrollRange(SB_HORZ, 0, xSize-1, false);
	SetScrollRange(SB_VERT, 0, ySize-1, false);

	// Set the scroll page size
	SetScrollPage(SB_HORZ, xVisible, false);
	SetScrollPage(SB_VERT, yVisible, false);

	// Reset the scroll position and be sure it is valid
	ResetScrollPos(SB_HORZ, xPos, bRedraw);
	ResetScrollPos(SB_VERT, yPos, bRedraw);
}
Beispiel #4
0
LRESULT CDocWindow::OnScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	UINT ScrollCode = LOWORD(wParam);
	UINT TrackCode = HIWORD(wParam);
	// SB_LINERIGHT, SB_LINEDOWN	Scrolls one line right/down
	// SB_LINELEFT, SB_LINEUP		Scrolls one line up/left
	// SB_PAGERIGHT, SB_PAGEDOWN	Scrolls one page right/down
	// SB_PAGELEFT, SB_PAGEUP		Scrolls one page left/up
	// SB_LEFT, SB_TOP				Scrolls to the start
	// SB_RIGHT, SB_BOTTOM			Scrolls to the end
	// SB_ENDSCROLL					Ends scroll
	// SB_THUMBPOSITION				The user has dragged the scroll box (thumb) and released the mouse button
	//								The high-order word indicates the position of the scroll box at the end of the drag operation
	// SB_THUMBTRACK				The user is dragging the scroll box
	//								This message is sent repeatedly until the user releases the mouse button
	//								The high-order word indicates the position that the scroll box has been dragged to

	int nMin = 0;
	int nMax = 0;
	if (uMsg == WM_HSCROLL)
	{
		GetScrollRange(SB_HORZ, &nMin, &nMax);
		int nPage = GetScrollPage(SB_HORZ);
		int nPos = GetScrollPos(SB_HORZ);
		switch (ScrollCode)
		{
			case SB_LINERIGHT:
			case SB_LINELEFT:
			{
				if (SB_LINERIGHT == ScrollCode)
					nPos += 100;
				else
					nPos -= 100;
				break;
			}
			case SB_PAGERIGHT:
			case SB_PAGELEFT:
			{
				if (SB_PAGERIGHT == ScrollCode)
					nPos += nPage;
				else
					nPos -= nPage;
				break;
			}
			case SB_RIGHT:
			case SB_LEFT:
			{
				if (SB_RIGHT == ScrollCode)
					nPos = nMax;
				else
					nPos = nMin;

				break;
			}
			case SB_THUMBTRACK:
			case SB_THUMBPOSITION:
			{
				nPos = TrackCode;
				break;
			}

			default:
				return S_OK;
		}

		if (nPos > nMax + 1 - nPage)
			nPos = nMax + 1 - nPage;
		if (nPos < nMin)
			nPos = nMin;

		SetScrollPos(SB_HORZ, nPos, true);
	}
	else
	if (uMsg == WM_VSCROLL)
	{
		GetScrollRange(SB_VERT, &nMin, &nMax);
		int nPage = GetScrollPage(SB_VERT);
		int nPos = GetScrollPos(SB_VERT);
		switch (ScrollCode)
		{
			case SB_LINEDOWN:
			case SB_LINEUP:
			{
				if (SB_LINEDOWN == ScrollCode)
					nPos += 100;
				else
					nPos -= 100;
				break;
			}
			case SB_PAGEDOWN:
			case SB_PAGEUP:
			{
				if (SB_PAGEDOWN == ScrollCode)
					nPos += nPage;
				else
					nPos -= nPage;
				break;
			}
			case SB_BOTTOM:
			case SB_TOP:
			{
				if (SB_BOTTOM == ScrollCode)
					nPos = nMax;
				else
					nPos = nMin;

				break;
			}
			case SB_THUMBTRACK:
			case SB_THUMBPOSITION:
			{
				nPos = TrackCode;
				break;
			}

			default:
				return S_OK;
		}

		if (nPos > nMax + 1 - nPage)
			nPos = nMax + 1 - nPage;
		if (nPos < nMin)
			nPos = nMin;

		SetScrollPos(SB_VERT, nPos, true);
	}

	SetupPageView(false/*bSetScrollbars*/);
	return S_OK;
}
/***
	响应垂直滚动条消息
*/
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;
	}
}