ImgEdit_UI/ImgEdit_UI/ScrollWnd.cpp
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;
}
// This function isn't virtual. If you need to override it,
// you really need to override OnMouseWheel() here or in
// CSplitterWnd.
This function isn't virtual. If you need to override it,
you really need to override OnMouseWheel() here or in
CSplitterWnd.
This function isn ' t virtual . If you need to override it you really need to override OnMouseWheel () here or in CSplitterWnd .
BOOL CScrollWnd::DoMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
	UNUSED_ALWAYS(point);
	UNUSED_ALWAYS(fFlags);
	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;
	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;
}
BOOL CScrollWnd :: DoMouseWheel ( UINT fFlags , short zDelta , CPoint point ) { UNUSED_ALWAYS ( point ) ; UNUSED_ALWAYS ( fFlags ) ; 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 ; 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 ; }
This function isn't virtual.
This function isn ' t virtual .
// 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 //_AfxGetMouseScrollLines();