コード例 #1
0
void CXTPPropertyPage::OnChildSetFocus(HWND hWndFocus)
{
	if ((GetStyle() & (WS_HSCROLL | WS_VSCROLL)) == 0)
		return;

	CWnd* pWnd = CWnd::FromHandle(hWndFocus);
	if (!pWnd)
		return;

	CRect rc;
	pWnd->GetWindowRect(rc);
	ScreenToClient(rc);

	CXTPClientRect rcClient(this);

	CSize szScroll(0, 0);

	if (rc.bottom > rcClient.bottom)
		szScroll.cy = rc.bottom - rcClient.bottom;
	if (rc.top - szScroll.cy < rcClient.top)
		szScroll.cy = rc.top - rcClient.top;

	if (rc.right > rcClient.right)
		szScroll.cx = rc.right - rcClient.right;
	if (rc.left - szScroll.cx < rcClient.left)
		szScroll.cx = rc.left - rcClient.left;

	if (szScroll != CSize(0, 0))
	{
		OnScrollBy(szScroll, TRUE);
	}
}
コード例 #2
0
BOOL CXTPPropertyPage::DoMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
	UNUSED_ALWAYS(point);
	UNUSED_ALWAYS(fFlags);

	// if we have a vertical scroll bar, the wheel scrolls that
	// if we have _only_ a horizontal scroll bar, the wheel scrolls that
	// otherwise, don't do any work at all

	DWORD dwStyle = GetStyle();
	CScrollBar* pBar = GetScrollBarCtrl(SB_VERT);
	BOOL bHasVertBar = ((pBar != NULL) && pBar->IsWindowEnabled()) ||
					(dwStyle & WS_VSCROLL);

	pBar = GetScrollBarCtrl(SB_HORZ);
	BOOL bHasHorzBar = ((pBar != NULL) && pBar->IsWindowEnabled()) ||
					(dwStyle & WS_HSCROLL);

	if (!bHasVertBar && !bHasHorzBar)
		return FALSE;

	BOOL bResult = FALSE;
	UINT uWheelScrollLines = 3;

	if (bHasVertBar)
	{
		bResult = OnScrollBy(CSize(0, (zDelta < 0 ? 1 : -1) * m_lineDev.cy * uWheelScrollLines), TRUE);
	}
	else if (bHasHorzBar)
	{
		bResult = OnScrollBy(CSize((zDelta < 0 ? 1 : -1) * m_lineDev.cy * uWheelScrollLines, 0), TRUE);
	}

	if (bResult)
		UpdateWindow();

	return bResult;
}
コード例 #3
0
BOOL CScrollWnd::DoMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
	UNUSED_ALWAYS(point);
	UNUSED_ALWAYS(fFlags);

	// if we have a vertical scroll bar, the wheel scrolls that
	// if we have _only_ a horizontal scroll bar, the wheel scrolls that
	// otherwise, don't do any work at all

	DWORD dwStyle = GetStyle();
	CScrollBar* pBar = GetScrollBarCtrl(SB_VERT);
	BOOL bHasVertBar = ((pBar != NULL) && pBar->IsWindowEnabled()) ||
					(dwStyle & WS_VSCROLL);

	pBar = GetScrollBarCtrl(SB_HORZ);
	BOOL bHasHorzBar = ((pBar != NULL) && pBar->IsWindowEnabled()) ||
					(dwStyle & WS_HSCROLL);

	if (!bHasVertBar && !bHasHorzBar)
		return FALSE;

	BOOL bResult = FALSE;
	UINT uWheelScrollLines = 10;//_AfxGetMouseScrollLines();
	int nToScroll;
	int nDisplacement;

	if (bHasVertBar)
	{
		nToScroll = ::MulDiv(-zDelta, uWheelScrollLines, WHEEL_DELTA);
		if (nToScroll == -1 || uWheelScrollLines == WHEEL_PAGESCROLL)
		{
			nDisplacement = m_pageDev.cy;
			if (zDelta > 0)
				nDisplacement = -nDisplacement;
		}
		else
		{
			nDisplacement = nToScroll * m_lineDev.cy;
			nDisplacement = min(nDisplacement, m_pageDev.cy);
		}
		bResult = OnScrollBy(CSize(0, nDisplacement), TRUE);
	}
	else if (bHasHorzBar)
	{
		nToScroll = ::MulDiv(-zDelta, uWheelScrollLines, WHEEL_DELTA);
		if (nToScroll == -1 || uWheelScrollLines == WHEEL_PAGESCROLL)
		{
			nDisplacement = m_pageDev.cx;
			if (zDelta > 0)
				nDisplacement = -nDisplacement;
		}
		else
		{
			nDisplacement = nToScroll * m_lineDev.cx;
			nDisplacement = min(nDisplacement, m_pageDev.cx);
		}
		bResult = OnScrollBy(CSize(nDisplacement, 0), TRUE);
	}

	if (bResult)
		UpdateWindow();

	return bResult;
}
コード例 #4
0
BOOL CScrollWnd::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	// calc new x position
	int x = GetScrollPos(SB_HORZ);
	int xOrig = x;
	
	switch (LOBYTE(nScrollCode))
	{
	case SB_TOP:
		x = 0;
		break;
	case SB_BOTTOM:
		x = INT_MAX;
		break;
	case SB_LINEUP:
		x -= m_lineDev.cx;
		break;
	case SB_LINEDOWN:
		x += m_lineDev.cx;
		break;
	case SB_PAGEUP:
		x -= m_pageDev.cx;
		break;
	case SB_PAGEDOWN:
		x += m_pageDev.cx;
		break;
	case SB_THUMBTRACK:
		x = nPos;
		break;
	}
	
	// calc new y position
	int y = GetScrollPos(SB_VERT);
	int yOrig = y;
	
	switch (HIBYTE(nScrollCode))
	{
	case SB_TOP:
		y = 0;
		break;
	case SB_BOTTOM:
		y = INT_MAX;
		break;
	case SB_LINEUP:
		y -= m_lineDev.cy;
		break;
	case SB_LINEDOWN:
		y += m_lineDev.cy;
		break;
	case SB_PAGEUP:
		y -= m_pageDev.cy;
		break;
	case SB_PAGEDOWN:
		y += m_pageDev.cy;
		break;
	case SB_THUMBTRACK:
		y = nPos;
		break;
	}
	
	BOOL bResult = OnScrollBy(CSize(x - xOrig, y - yOrig), bDoScroll);
	if (bResult && bDoScroll)
		UpdateWindow();
	
	return bResult;
}
コード例 #5
0
ファイル: ScrView.cpp プロジェクト: KB3NZQ/hexedit4
BOOL CScrView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	CPointAp newpos = scrollpos_;

	switch (LOBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.x = 0;
		break;
	case SB_BOTTOM:
		newpos.x = total_.cx - win_width_;
		break;
	case SB_LINEUP:
		newpos.x -= line_.cx;
		break;
	case SB_LINEDOWN:
		newpos.x += line_.cx;
		break;
	case SB_PAGEUP:
		newpos.x -= page_.cx;
		break;
	case SB_PAGEDOWN:
		newpos.x += page_.cx;
		break;
	case SB_THUMBPOSITION:
		// DoInvalidate here as this event sent after mouse released after
		// all SB_THUMBTRACK events.  This removes any bits of the scroll-
		// bar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.x = (int)(((__int64)nPos * total_.cx) / maxbar_.cx);
		if (total_.cx > maxbar_.cx && newpos.x > total_.cx - win_width_)
			newpos.x = total_.cx - win_width_;
		break;
	}

	switch (HIBYTE(nScrollCode))
	{
	case SB_TOP:
		newpos.y = 0;
		break;
	case SB_BOTTOM:
		newpos.y = total_.cy - win_height_;
		break;
	case SB_LINEUP:
		newpos.y -= line_.cy;
		break;
	case SB_LINEDOWN:
		newpos.y += line_.cy;
		break;
	case SB_PAGEUP:
		newpos.y -= page_.cy;
		break;
	case SB_PAGEDOWN:
		newpos.y += page_.cy;
		break;
	case SB_THUMBPOSITION:
		// Invalidate here as this event sent after mouse released after
		// SB_THUMBTRACK events finished.  This removes any bits of the
		// scrollbar left after tracking caused the scroll bar to "evaporate".
		DoInvalidate();
		// fall through
	case SB_THUMBTRACK:
		newpos.y = ((__int64)nPos * total_.cy) / maxbar_.cy;
		if (total_.cy > maxbar_.cy && newpos.y > total_.cy - win_height_)
			newpos.y = total_.cy - win_height_;
		break;
	}

#if 0
	if (bDoScroll)
		ValidateScroll(newpos);
	// Work out amount to scroll (in device coordinates)
	{
		CClientDC dc(this);
		OnPrepareDC(&dc);
		CSize amt = CSize(newpos - scrollpos_); // This won't work
		dc.LPtoDP(&amt);
	}
	BOOL retval = OnScrollBy(amt, bDoScroll);
	if (retval && bDoScroll)
		DoUpdateWindow();

	return retval;
#else
	if (bDoScroll)
	{
		ValidateScroll(newpos);
		update_bars(newpos);
		DoUpdateWindow();
	}
	return TRUE;
#endif
}
コード例 #6
0
ファイル: scrollvw.cpp プロジェクト: ABratovic/open-watcom-v2
BOOL CScrollView::OnScroll( UINT nScrollCode, UINT nPos, BOOL bDoScroll )
/***********************************************************************/
{
    CRect rectClient;
    GetClientRect( &rectClient );

    BOOL    bHasX = m_totalDev.cx > rectClient.Width();
    BOOL    bHasY = m_totalDev.cy > rectClient.Height();
    
    int nHorzPos = GetScrollPos( SB_HORZ );
    switch( LOBYTE( nScrollCode ) ) {
    case SB_LEFT:
        nHorzPos = 0;
        break;
    case SB_LINELEFT:
        nHorzPos -= m_lineDev.cx;
        break;
    case SB_LINERIGHT:
        nHorzPos += m_lineDev.cx;
        break;
    case SB_PAGELEFT:
        nHorzPos -= m_pageDev.cx;
        break;
    case SB_PAGERIGHT:
        nHorzPos += m_pageDev.cx;
        break;
    case SB_RIGHT:
        nHorzPos = m_totalDev.cx;
        break;
    case SB_THUMBPOSITION:
        nHorzPos = nPos;
        break;
    case SB_THUMBTRACK:
        nHorzPos = nPos;
        break;
    }
    
    int nVertPos = GetScrollPos( SB_VERT );
    switch( HIBYTE( nScrollCode ) ) {
    case SB_BOTTOM:
        nVertPos = m_totalDev.cy;
        break;
    case SB_LINEDOWN:
        nVertPos += m_lineDev.cy;
        break;
    case SB_LINEUP:
        nVertPos -= m_lineDev.cy;
        break;
    case SB_PAGEDOWN:
        nVertPos += m_pageDev.cy;
        break;
    case SB_PAGEUP:
        nVertPos -= m_pageDev.cy;
        break;
    case SB_THUMBPOSITION:
        nVertPos = nPos;
        break;
    case SB_THUMBTRACK:
        nVertPos = nPos;
        break;
    case SB_TOP:
        nVertPos = 0;
        break;
    }
    if( nVertPos < 0 ) {
        nVertPos = 0;
    }

    return( OnScrollBy( CSize( nHorzPos - GetScrollPos( SB_HORZ ),
                               nVertPos - GetScrollPos( SB_VERT ) ), bDoScroll ) );
}
コード例 #7
0
ファイル: BigView.cpp プロジェクト: cmosher01/OpenGRO
BOOL CBigScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll)
{
	// calc new x position
	int x = GetScrollPos(SB_HORZ);
	int xOrig = x;

	switch (LOBYTE(nScrollCode))
	{
		case SB_TOP:
			x = 0;
			break;
		case SB_BOTTOM:
			x = INT_MAX;
			break;
		case SB_LINEUP:
			x -= m_lineDev.cx;
			break;
		case SB_LINEDOWN:
			x += m_lineDev.cx;
			break;
		case SB_PAGEUP:
			x -= m_pageDev.cx;
			break;
		case SB_PAGEDOWN:
			x += m_pageDev.cx;
			break;
		case SB_THUMBTRACK:
		{
			SCROLLINFO si;
			si.fMask = SIF_TRACKPOS;
			si.cbSize = sizeof(SCROLLINFO);
			GetScrollInfo(SB_HORZ,&si,SIF_TRACKPOS);
			x = si.nTrackPos;
			break;
		}
	}

	// calc new y position
	int y = GetScrollPos(SB_VERT);
	int yOrig = y;

	switch (HIBYTE(nScrollCode))
	{
		case SB_TOP:
			y = 0;
			break;
		case SB_BOTTOM:
			y = INT_MAX;
			break;
		case SB_LINEUP:
			y -= m_lineDev.cy;
			break;
		case SB_LINEDOWN:
			y += m_lineDev.cy;
			break;
		case SB_PAGEUP:
			y -= m_pageDev.cy;
			break;
		case SB_PAGEDOWN:
			y += m_pageDev.cy;
			break;
		case SB_THUMBTRACK:
		{
			SCROLLINFO si;
			si.fMask = SIF_TRACKPOS;
			si.cbSize = sizeof(SCROLLINFO);
			GetScrollInfo(SB_VERT,&si,SIF_TRACKPOS);
			y = si.nTrackPos;
			break;
		}
	}

	BOOL bResult = OnScrollBy(wxSize(x - xOrig, y - yOrig), bDoScroll);
	if (bResult && bDoScroll)
		UpdateWindow();

	return bResult;
}