ExtScrollWnd.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:206k
- // This is part of the Professional User Interface Suite library.
- // Copyright (C) 2001-2009 FOSS Software, Inc.
- // All rights reserved.
- //
- // http://www.prof-uis.com
- // mailto:support@prof-uis.com
- //
- // This source code can be used, modified and redistributed
- // under the terms of the license agreement that is included
- // in the Professional User Interface Suite package.
- //
- // Warranties and Disclaimers:
- // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
- // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
- // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
- // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- #include "stdafx.h"
- #if (!defined __EXT_SCROLLWND_H)
- #include <ExtScrollWnd.h>
- #endif
- #if (!defined __AFXPRIV_H__)
- #include <AfxPriv.h>
- #endif
- #if (!defined __EXT_TOOLCONTROLBAR_H)
- #include <ExtToolControlBar.h>
- #endif
- #if (!defined __EXT_POPUP_MENU_WND_H)
- #include <ExtPopupMenuWnd.h>
- #endif
- #if (!defined __EXT_PAINT_MANAGER_H)
- #include <ExtPaintManager.h>
- #endif
- #if (!defined __EXT_MEMORY_DC_H)
- #include <../src/ExtMemoryDC.h>
- #endif
- #if _MFC_VER < 0x700
- #include <../src/AfxImpl.h>
- #else
- #ifndef __AFXSTATE_H__
- #include <../src/mfc/afxstat_.h>
- #endif
- #include <../src/mfc/AfxImpl.h>
- #endif
- #if (!defined __EXT_LOCALIZATION_H)
- #include <../Src/ExtLocalization.h>
- #endif
- #if (!defined __EXT_STATUSCONTROLBAR_H)
- #include <ExtStatusControlBar.h>
- #endif
- #include <Resources/Resource.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CExtScrollBar
- IMPLEMENT_DYNCREATE( CExtScrollBar, CScrollBar );
- CExtScrollBar::CExtScrollBar()
- : m_bAutoDeleteOnPostNcDestroy( false )
- , m_bReflectParentSizing( true )
- , m_eSO( CExtScrollBar::__ESO_AUTO )
- , m_bDisableAutoReserveSpace( false )
- , m_bAutoReserveSpaceBefore( false )
- , m_bAutoReserveSpaceAfter( false )
- , m_bSmoothPainting( true )
- , m_hWndBefore( NULL )
- , m_hWndAfter( NULL )
- , m_bHideHwndBefore( false )
- , m_bHideHwndAfter( false )
- , m_bCompleteRepaint( true )
- , m_nHorzBarHeight( 0 )
- , m_nVertBarWidth( 0 )
- , m_nHorzButtonWidth( 0 )
- , m_nVertButtonHeight( 0 )
- , m_nHorzThumbMinWidth( 0 )
- , m_nVertThumbMinHeight( 0 )
- , m_bProcessingClick( false )
- , m_bProcessingOutClick( false )
- , m_bProcessingHover( false )
- , m_bProcessingCancelMode( false )
- , m_nSBMHT( INT(CExtPaintManager::__ESBMHT_NOWHERE) )
- , m_nHelperTrackPos( -1 )
- , m_bHelperHaveTrackPos( false )
- , m_bHelperLightAccent( true )
- , m_bEnabledToolTips( false )
- , m_bEnabledTrackingToolTips( false )
- , m_bEnableHookSpy( false )
- , m_bHookCapturedState( false )
- , m_nMouseActivateCode( MA_ACTIVATE )
- , m_bSendActionNotifications( true )
- , m_bPopupInactiveLightMode( false )
- , m_nStepSize( 1 )
- , m_bAlwaysSendThumbButtonNotifications( false )
- , m_bSendEqualNotifications( false )
- , m_ptCtxMenuCache( 0, 0 )
- , m_bEnableCtxMenu( false )
- {
- m_bHookConvertLocationsToClient = true;
- if( ! g_PaintManager.m_bIsWinNT4orLater )
- m_bCompleteRepaint = false;
- /*
- ::memset( &m_scrollInfo, 0, sizeof(SCROLLINFO) );
- m_scrollInfo.cbSize = sizeof(SCROLLINFO);
- m_scrollInfo.fMask = SIF_ALL;
- */
- }
- CExtScrollBar::~CExtScrollBar()
- {
- CExtAnimationSite * pAcAS = AnimationClient_SiteGet();
- if( pAcAS != NULL )
- pAcAS->AnimationSite_ClientRemove( this );
- }
- INT CExtScrollBar::GetStepSize() const
- {
- ASSERT_VALID( this );
- return m_nStepSize;
- }
- BEGIN_MESSAGE_MAP(CExtScrollBar, CScrollBar)
- //{{AFX_MSG_MAP(CExtScrollBar)
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_WINDOWPOSCHANGING()
- ON_WM_WINDOWPOSCHANGED()
- ON_WM_SIZE()
- ON_WM_NCCALCSIZE()
- ON_WM_CONTEXTMENU()
- ON_WM_MOUSEACTIVATE()
- ON_WM_SHOWWINDOW()
- ON_WM_ENABLE()
- ON_WM_CANCELMODE()
- ON_WM_CAPTURECHANGED()
- ON_WM_SETCURSOR()
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_LBUTTONDBLCLK()
- ON_WM_MBUTTONDOWN()
- ON_WM_MBUTTONUP()
- ON_WM_MBUTTONDBLCLK()
- ON_WM_RBUTTONDOWN()
- ON_WM_RBUTTONUP()
- ON_WM_RBUTTONDBLCLK()
- //}}AFX_MSG_MAP
- __EXT_MFC_ON_WM_NCHITTEST()
- ON_WM_TIMER()
- __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_MESSAGE( WM_SIZEPARENT, OnSizeParent )
- ON_COMMAND( __EXT_ID_SCROLL_HERE, OnScrollHere )
- ON_COMMAND( __EXT_ID_SCROLL_EDGE_LOWER, OnScrollEdgeLower )
- ON_COMMAND( __EXT_ID_SCROLL_EDGE_UPPER, OnScrollEdgeUpper )
- ON_COMMAND( __EXT_ID_SCROLL_PAGE_LOWER, OnScrollPageLower )
- ON_COMMAND( __EXT_ID_SCROLL_PAGE_UPPER, OnScrollPageUpper )
- ON_COMMAND( __EXT_ID_SCROLL_LINE_LOWER, OnScrollLineLower )
- ON_COMMAND( __EXT_ID_SCROLL_LINE_UPPER, OnScrollLineUpper )
- END_MESSAGE_MAP()
- bool CExtScrollBar::AnimationClient_EnabledGet() const
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return false;
- return CExtAnimationSingleton::AnimationClient_EnabledGet();
- }
- bool CExtScrollBar::AnimationSite_EnabledGet() const
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return false;
- return CExtAnimationSingleton::AnimationSite_EnabledGet();
- }
- void CExtScrollBar::AnimationSite_OnProgressShutdownTimer( UINT nTimerID )
- {
- ASSERT_VALID( this );
- CExtAnimationSingleton::AnimationSite_OnProgressShutdownTimer( nTimerID );
- // AnimationClient_StateGet( false ).Empty();
- // AnimationClient_StateGet( true ).Empty();
- }
- HWND CExtScrollBar::AnimationSite_GetSafeHWND() const
- {
- __PROF_UIS_MANAGE_STATE;
- HWND hWnd = GetSafeHwnd();
- return hWnd;
- }
- const CExtAnimationParameters *
- CExtScrollBar::AnimationClient_OnQueryAnimationParameters(
- INT eAPT // __EAPT_*** animation type
- ) const
- {
- ASSERT_VALID( this );
- //return (&PmBridge_GetPM()->g_DefAnimationParametersVerySlow);
- const CExtAnimationParameters * pAnimationParameters =
- PmBridge_GetPM()->Animation_GetParameters(
- eAPT,
- (CObject*)this,
- this
- );
- return pAnimationParameters;
- }
- bool CExtScrollBar::AnimationClient_CacheNextState(
- CDC & dc,
- const RECT & rcAcAnimationTarget,
- bool bAnimate,
- INT eAPT // __EAPT_*** animation type
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( AnimationClient_CacheGeneratorIsLocked() );
- OnSbPaint( dc );
-
- return
- CExtAnimationSingleton::AnimationClient_CacheNextState(
- dc,
- rcAcAnimationTarget,
- bAnimate,
- eAPT
- );
- }
- void CExtScrollBar::PmBridge_OnPaintManagerChanged(
- CExtPaintManager * pGlobalPM
- )
- {
- ASSERT_VALID( this );
- CExtAnimationSingleton::PmBridge_OnPaintManagerChanged( pGlobalPM );
- if( m_bCompleteRepaint )
- {
- _ScanSysMertics();
- if( GetSafeHwnd() != NULL )
- {
- SetWindowPos(
- NULL, 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_NOACTIVATE|SWP_FRAMECHANGED
- );
- Invalidate();
- }
- } // if( m_bCompleteRepaint )
- }
- void CExtScrollBar::_ScanSysMertics()
- {
- ASSERT_VALID( this );
- bool bGetDefaultMetrics = true;
- if( m_bCompleteRepaint )
- {
- if( PmBridge_GetPM()->ScrollBar_GetMetrics(
- &m_nHorzBarHeight,
- &m_nVertBarWidth,
- &m_nHorzButtonWidth,
- &m_nVertButtonHeight,
- &m_nHorzThumbMinWidth,
- &m_nVertThumbMinHeight,
- this
- )
- )
- bGetDefaultMetrics = false;
- } // if( m_bCompleteRepaint )
- if( bGetDefaultMetrics )
- {
- m_nHorzBarHeight = ::GetSystemMetrics( SM_CYHSCROLL );
- m_nVertBarWidth = ::GetSystemMetrics( SM_CXVSCROLL );
- m_nHorzButtonWidth = ::GetSystemMetrics( SM_CXHSCROLL );
- m_nVertButtonHeight = ::GetSystemMetrics( SM_CYVSCROLL );
- m_nHorzThumbMinWidth = 9; // ::GetSystemMetrics( SM_CXHTHUMB );
- m_nVertThumbMinHeight = 9; // ::GetSystemMetrics( SM_CYVTHUMB );
- } // if( bGetDefaultMetrics )
- }
- void CExtScrollBar::SyncReservedSpace( CExtScrollBar * pOtherBar )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pOtherBar );
- ASSERT( this != pOtherBar );
- CWnd * pWndNext = GetWindow( GW_HWNDNEXT );
- if( pWndNext != pOtherBar )
- return;
- m_bAutoReserveSpaceBefore = m_bAutoReserveSpaceAfter = false;
- pOtherBar->m_bAutoReserveSpaceBefore = pOtherBar->m_bAutoReserveSpaceAfter = false;
- if( m_bDisableAutoReserveSpace )
- return;
- if( (GetStyle()&WS_VISIBLE) == 0 || (pOtherBar->GetStyle()&WS_VISIBLE) == 0 )
- return;
- eScrollerOrientation_t _eSOown = GetScrollerOrientation();
- eScrollerOrientation_t _eSOother = pOtherBar->GetScrollerOrientation();
- switch( _eSOown )
- {
- case __ESO_TOP:
- case __ESO_BOTTOM:
- switch( _eSOother )
- {
- case __ESO_LEFT:
- m_bAutoReserveSpaceBefore = true;
- break;
- case __ESO_RIGHT:
- m_bAutoReserveSpaceAfter = true;
- break;
- case __ESO_TOP:
- case __ESO_BOTTOM:
- case __ESO_NONE:
- return;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- return;
- #endif // _DEBUG
- } // switch( _eSOother )
- break;
- case __ESO_LEFT:
- case __ESO_RIGHT:
- switch( _eSOother )
- {
- case __ESO_TOP:
- m_bAutoReserveSpaceBefore = true;
- break;
- case __ESO_BOTTOM:
- m_bAutoReserveSpaceAfter = true;
- break;
- case __ESO_LEFT:
- case __ESO_RIGHT:
- case __ESO_NONE:
- return;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- return;
- #endif // _DEBUG
- } // switch( _eSOother )
- break;
- case __ESO_NONE:
- return;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- return;
- #endif // _DEBUG
- } // switch( _eSOown )
- }
- CExtScrollBar::eScrollerOrientation_t
- CExtScrollBar::GetScrollerOrientation() const
- {
- ASSERT_VALID( this );
- ASSERT( __ESO_MIN_VALUE <= m_eSO && m_eSO <= __ESO_MAX_VALUE );
- eScrollerOrientation_t _eSO = m_eSO;
- if( _eSO == __ESO_AUTO )
- {
- DWORD dwWndStyle = CWnd::GetStyle();
- if( ( dwWndStyle & (SBS_TOPALIGN|SBS_VERT) ) == (SBS_TOPALIGN) )
- _eSO = __ESO_TOP;
- else if( ( dwWndStyle & (SBS_BOTTOMALIGN|SBS_VERT) ) == (SBS_BOTTOMALIGN) )
- _eSO = __ESO_BOTTOM;
- else if( ( dwWndStyle & (SBS_LEFTALIGN|SBS_VERT) ) == (SBS_LEFTALIGN|SBS_VERT) )
- _eSO = __ESO_LEFT;
- else if( ( dwWndStyle & (SBS_RIGHTALIGN|SBS_VERT) ) == (SBS_RIGHTALIGN|SBS_VERT) )
- _eSO = __ESO_RIGHT;
- else if( ( dwWndStyle & SBS_VERT ) != 0 )
- _eSO = __ESO_RIGHT;
- else
- _eSO = __ESO_BOTTOM;
- // _eSO = __ESO_NONE;
- } // if( _eSO == __ESO_AUTO )
- return _eSO;
- }
- void CExtScrollBar::PreSubclassWindow()
- {
- m_bProcessingClick
- = m_bProcessingOutClick
- = m_bProcessingHover
- = m_bProcessingCancelMode
- = m_bHelperHaveTrackPos
- = false;
- m_nHelperTrackPos = -1;
- m_nSBMHT = INT(CExtPaintManager::__ESBMHT_NOWHERE);
- CScrollBar::PreSubclassWindow();
- if( ( ! IsKindOf( RUNTIME_CLASS(CExtZoomScrollBar) ) )
- && ( (GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- )
- ModifyStyleEx( WS_EX_LAYOUTRTL, 0, SWP_FRAMECHANGED );
- _ScanSysMertics();
- AnimationSite_ClientProgressStop( this );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- CRect rcClient;
- GetClientRect( &rcClient );
- AnimationClient_TargetRectSet( rcClient );
- if( m_bEnableHookSpy )
- HookSpyRegister( __EHSEF_MOUSE_ALL_WITHOUT_WHEEL|__EHSEF_WND_PROC_IN|__EHSEF_PRE_TRANSLATION );
- }
- LRESULT CExtScrollBar::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- LRESULT lResult =
- CScrollBar::DefWindowProc( message, wParam, lParam );
- return lResult;
- }
- LRESULT CExtScrollBar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- if( message == WM_PRINT || message == WM_PRINTCLIENT )
- {
- CDC * pDC = CDC::FromHandle( (HDC)wParam );
- if( m_bCompleteRepaint )
- OnSbPaint( *pDC );
- else
- DefWindowProc( WM_PAINT, (WPARAM)pDC->GetSafeHdc(), 0L );
- return (!0);
- }
- bool bUnLockRedraw = false;
- HWND hWndOwn = m_hWnd;
- if( hWndOwn != NULL
- && ::IsWindow( hWndOwn )
- && m_bCompleteRepaint
- && _IsLockAbleMessage( message )
- && (GetStyle()&WS_VISIBLE) != 0
- )
- {
- bUnLockRedraw = true;
- ::SendMessage( hWndOwn, WM_SETREDRAW, FALSE, 0 );
- }
- LRESULT lResult = CScrollBar::WindowProc( message, wParam, lParam );
- if( message == SBM_GETSCROLLINFO
- && m_bCompleteRepaint
- && lResult != 0L
- )
- {
- SCROLLINFO * pSI = (SCROLLINFO *)lParam;
- if( pSI != NULL
- && pSI->cbSize == sizeof(SCROLLINFO)
- && ( ( pSI->fMask & SIF_TRACKPOS ) != 0 )
- && m_bHelperHaveTrackPos // && m_nHelperTrackPos != -1
- )
- pSI->nTrackPos = m_nHelperTrackPos;
- }
- /*
- //if( m_bCompleteRepaint )
- {
- switch( message )
- {
- case SBM_GETPOS:
- lResult = LRESULT(m_scrollInfo.nPos);
- break;
- case SBM_SETPOS:
- m_scrollInfo.nPos = INT(wParam);
- m_scrollInfo.nPos = max( m_scrollInfo.nPos, m_scrollInfo.nMin );
- m_scrollInfo.nPos = min( m_scrollInfo.nPos, m_scrollInfo.nMax );
- lResult = LRESULT(m_scrollInfo.nPos);
- if( lParam != 0 )
- Invalidate();
- break;
- case SBM_GETRANGE:
- {
- LPINT pMin = (LPINT)wParam;
- LPINT pMax = (LPINT)lParam;
- if( pMin != NULL )
- (*pMin) = m_scrollInfo.nMin;
- if( pMax != NULL )
- (*pMax) = m_scrollInfo.nMax;
- }
- break;
- case SBM_SETRANGEREDRAW:
- Invalidate();
- // continue falling
- case SBM_SETRANGE:
- m_scrollInfo.nMin = INT(wParam);
- m_scrollInfo.nMax = INT(lParam);
- m_scrollInfo.nMax = max( m_scrollInfo.nMax, m_scrollInfo.nMin );
- m_scrollInfo.nTrackPos = max( m_scrollInfo.nTrackPos, m_scrollInfo.nMin );
- m_scrollInfo.nTrackPos = min( m_scrollInfo.nTrackPos, m_scrollInfo.nMax );
- m_scrollInfo.nPos = max( m_scrollInfo.nPos, m_scrollInfo.nMin );
- m_scrollInfo.nPos = min( m_scrollInfo.nPos, m_scrollInfo.nMax );
- lResult = LRESULT(m_scrollInfo.nPos);
- break;
- //case SBM_ENABLE_ARROWS:
- //break;
- case SBM_GETSCROLLINFO:
- {
- lResult = 0;
- SCROLLINFO * pSI = (SCROLLINFO*)lParam;
- if( pSI != NULL && pSI->cbSize >= sizeof(SCROLLINFO) )
- {
- if( ( pSI->fMask & SIF_POS ) != 0 )
- {
- lResult = 1;
- pSI->nPos = m_scrollInfo.nPos;
- }
- if( ( pSI->fMask & SIF_TRACKPOS ) != 0 )
- {
- lResult = 1;
- pSI->nTrackPos = m_scrollInfo.nTrackPos;
- }
- if( ( pSI->fMask & SIF_PAGE ) != 0 )
- {
- lResult = 1;
- pSI->nPage = m_scrollInfo.nPage;
- }
- if( ( pSI->fMask & SIF_RANGE ) != 0 )
- {
- lResult = 1;
- pSI->nMin = m_scrollInfo.nMin;
- pSI->nMax = m_scrollInfo.nMax;
- }
- }
- }
- break;
- case SBM_SETSCROLLINFO:
- {
- SCROLLINFO * pSI = (SCROLLINFO*)lParam;
- if( pSI != NULL && pSI->cbSize >= sizeof(SCROLLINFO) )
- {
- if( ( pSI->fMask & SIF_POS ) != 0 )
- m_scrollInfo.nPos = pSI->nPos;
- if( ( pSI->fMask & SIF_TRACKPOS ) != 0 )
- m_scrollInfo.nTrackPos = pSI->nTrackPos;
- if( ( pSI->fMask & SIF_PAGE ) != 0 )
- m_scrollInfo.nPage = pSI->nPage;
- if( ( pSI->fMask & SIF_RANGE ) != 0 )
- {
- m_scrollInfo.nMin = pSI->nMin;
- m_scrollInfo.nMax = pSI->nMax;
- }
- }
- m_scrollInfo.nMax = max( m_scrollInfo.nMax, m_scrollInfo.nMin );
- m_scrollInfo.nTrackPos = max( m_scrollInfo.nTrackPos, m_scrollInfo.nMin );
- m_scrollInfo.nTrackPos = min( m_scrollInfo.nTrackPos, m_scrollInfo.nMax );
- m_scrollInfo.nPos = max( m_scrollInfo.nPos, m_scrollInfo.nMin );
- m_scrollInfo.nPos = min( m_scrollInfo.nPos, m_scrollInfo.nMax );
- lResult = LRESULT(m_scrollInfo.nPos);
- if( wParam != 0 )
- Invalidate();
- }
- break;
- } // switch( message )
- }
- */
- if( hWndOwn != NULL
- && ::IsWindow( hWndOwn )
- && bUnLockRedraw
- )
- {
- CWnd * pWnd = CWnd::FromHandlePermanent( hWndOwn );
- if( pWnd == this )
- {
- ::SendMessage( hWndOwn, WM_SETREDRAW, TRUE, 0 );
- if( (GetStyle()&WS_VISIBLE) != 0 )
- {
- Invalidate();
- if( ScrollBar_CaptureGet() == m_hWnd )
- UpdateWindow();
- }
- }
- }
- return lResult;
- }
- bool CExtScrollBar::_IsLockAbleMessage( UINT message ) const
- {
- if( ! m_bCompleteRepaint )
- return false;
- switch( message )
- {
- case SBM_SETPOS:
- case SBM_SETRANGE:
- case SBM_SETRANGEREDRAW:
- case SBM_SETSCROLLINFO:
- case SBM_ENABLE_ARROWS:
- return true;
- } // switch( message )
- return false;
- }
- INT CExtScrollBar::_GetScrollPos(
- bool bTrackPos // = false
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- CScrollBar * pSB = ( CScrollBar * )this;
- if( pSB->GetScrollInfo(
- &_scroll_info,
- bTrackPos ? SIF_TRACKPOS : SIF_POS
- )
- )
- {
- LONG nRetVal = (LONG)
- ( bTrackPos
- ? _scroll_info.nTrackPos
- : _scroll_info.nPos
- );
- return nRetVal;
- }
- return CScrollBar::GetScrollPos();
- }
- void CExtScrollBar::_SetScrollPos(
- INT nPos,
- bool bTrackPos, // = false
- bool bRedraw, // = true
- bool bSendScrollingNotification // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- AnimationSite_ClientProgressStop( this );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- CExtPaintManager::PAINTSCROLLBARDATA _psbd( this );
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- if( bTrackPos )
- {
- _scroll_info.fMask = SIF_TRACKPOS;
- _scroll_info.nTrackPos = (int)nPos;
- }
- else
- {
- _scroll_info.fMask = SIF_POS;
- _scroll_info.nPos = (int)nPos;
- }
- m_nHelperTrackPos = (int)nPos;
- if( ! CScrollBar::SetScrollInfo(
- &_scroll_info,
- bRedraw ? TRUE : FALSE
- )
- )
- CScrollBar::SetScrollPos( nPos, bRedraw ? TRUE : FALSE );
- else
- bRedraw = false;
- if( bSendScrollingNotification
- && _psbd.m_bEnabled
- && ( m_nSBMHT == CExtPaintManager::__ESBMHT_THUMB
- || m_bAlwaysSendThumbButtonNotifications
- )
- )
- {
- HWND hWndParent = ::GetParent( m_hWnd );
- if( hWndParent != NULL )
- {
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM(
- ( bTrackPos ? SB_THUMBTRACK : SB_THUMBPOSITION ),
- nPos
- ),
- LPARAM(m_hWnd)
- );
- }
- }
- if( bRedraw )
- {
- Invalidate();
- if( ScrollBar_CaptureGet() == m_hWnd )
- UpdateWindow();
- }
- }
- CExtNCSB_ScrollContainer * CExtScrollBar::_GetParentScrollContainer()
- {
- if( GetSafeHwnd() == NULL )
- return NULL;
- ASSERT_VALID( this );
- HWND hWndParent = ::GetParent( m_hWnd );
- if( hWndParent == NULL )
- return NULL;
- CWnd * pWndParent = CWnd::FromHandlePermanent( hWndParent );
- if( pWndParent == NULL )
- return NULL;
- CExtNCSB_ScrollContainer * pScrollContainer = DYNAMIC_DOWNCAST( CExtNCSB_ScrollContainer, pWndParent );
- return pScrollContainer;
- }
- CExtPopupMenuTipWnd * CExtScrollBar::OnAdvancedPopupMenuTipWndGet() const
- {
- if( ! m_bEnabledToolTips )
- return NULL;
- return (&( CExtPopupMenuSite::g_DefPopupMenuSite.GetTip() ));
- }
- bool CExtScrollBar::OnAdvancedPopupMenuTipWndGetInfo(
- CExtPopupMenuTipWnd & _ATTW,
- INT nSBMHT,
- bool bTrackingTip,
- CRect & rcExcludeArea,
- CExtSafeString & strTipText
- ) const
- {
- ASSERT_VALID( this );
- _ATTW;
- strTipText.Empty();
- if( ( ! m_bEnabledToolTips )
- || ( bTrackingTip && ( ! m_bEnabledTrackingToolTips ) )
- )
- return false;
- CExtPaintManager::PAINTSCROLLBARDATA _psbd(
- const_cast < CExtScrollBar * > ( this ),
- bTrackingTip,
- CExtPaintManager::e_scroll_bar_mouse_hover_type_t(nSBMHT)
- );
- switch( nSBMHT )
- {
- case INT(CExtPaintManager::__ESBMHT_BUTTON_UP):
- rcExcludeArea = _psbd.m_rcButtonUp;
- strTipText = m_strTipTextForUpButton;
- break;
- case INT(CExtPaintManager::__ESBMHT_BUTTON_DOWN):
- rcExcludeArea = _psbd.m_rcButtonDown;
- strTipText = m_strTipTextForDownButton;
- break;
- case INT(CExtPaintManager::__ESBMHT_THUMB):
- rcExcludeArea = _psbd.m_rcThumb;
- strTipText = m_strTipTextForThumbButton;
- break;
- case INT(CExtPaintManager::__ESBMHT_PAGE_UP):
- rcExcludeArea = _psbd.m_rcPageUp;
- strTipText = m_strTipTextForPageUpArea;
- break;
- case INT(CExtPaintManager::__ESBMHT_PAGE_DOWN):
- rcExcludeArea = _psbd.m_rcPageDown;
- strTipText = m_strTipTextForPageDownArea;
- break;
- default:
- return false;
- } // switch( nSBMHT )
- ClientToScreen( &rcExcludeArea );
- return true;
- }
- void CExtScrollBar::OnAdvancedPopupMenuTipWndDisplay(
- CExtPopupMenuTipWnd & _ATTW,
- INT nSBMHT,
- bool bTrackingTip
- ) const
- {
- ASSERT_VALID( this );
- if( ( ! m_bEnabledToolTips )
- || ( bTrackingTip && ( ! m_bEnabledTrackingToolTips ) )
- )
- {
- _ATTW.Hide();
- return;
- }
- CRect rcExcludeArea( 0, 0, 0, 0 );
- CExtSafeString strTipText;
- if( ! OnAdvancedPopupMenuTipWndGetInfo(
- _ATTW,
- nSBMHT,
- bTrackingTip,
- rcExcludeArea,
- strTipText
- )
- )
- {
- _ATTW.Hide();
- return;
- }
- if( strTipText.IsEmpty() )
- {
- _ATTW.Hide();
- return;
- }
- OnAdvancedPopupMenuTipWndDisplay(
- _ATTW,
- rcExcludeArea,
- LPCTSTR( strTipText ),
- bTrackingTip
- );
- }
- void CExtScrollBar::OnAdvancedPopupMenuTipWndDisplay(
- CExtPopupMenuTipWnd & _ATTW,
- const RECT & rcExcludeArea,
- __EXT_MFC_SAFE_LPCTSTR strTipText,
- bool bTrackingTip
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( strTipText != NULL && _tcslen( strTipText ) > 0 );
- if( ( ! m_bEnabledToolTips )
- || ( bTrackingTip && ( ! m_bEnabledTrackingToolTips ) )
- )
- {
- _ATTW.Hide();
- return;
- }
- if( _ATTW.GetSafeHwnd() != NULL
- && (_ATTW.GetStyle()&WS_VISIBLE) != 0
- && _ATTW.GetExcludeArea() == rcExcludeArea
- )
- {
- LPCTSTR strTipTextOld = _ATTW.GetText();
- if( strTipTextOld != NULL
- && _tcscmp( strTipTextOld, strTipText ) == 0
- )
- return;
- }
- if( m_eSO == __ESO_BOTTOM )
- _ATTW.SetTipStyle( CExtPopupMenuTipWnd::__ETS_INV_RECTANGLE_NO_ICON );
- else
- _ATTW.SetTipStyle( CExtPopupMenuTipWnd::__ETS_RECTANGLE_NO_ICON );
- _ATTW.SetText( strTipText );
- _ATTW.Show( (CWnd*)this, rcExcludeArea, bTrackingTip );
- if( bTrackingTip )
- CExtPaintManager::stat_PassPaintMessages();
- }
- void CExtScrollBar::PostNcDestroy()
- {
- ASSERT_VALID( this );
- m_bProcessingClick
- = m_bProcessingOutClick
- = m_bProcessingHover
- = m_bProcessingCancelMode
- = m_bHelperHaveTrackPos
- = false;
- m_nHelperTrackPos = -1;
- m_nSBMHT = INT(CExtPaintManager::__ESBMHT_NOWHERE);
- if( m_bEnableHookSpy )
- HookSpyUnregister();
- if( m_bAutoDeleteOnPostNcDestroy )
- delete this;
- }
- BOOL CExtScrollBar::OnEraseBkgnd(CDC* pDC)
- {
- if( (! m_bSmoothPainting ) && (! m_bCompleteRepaint ) )
- return CScrollBar::OnEraseBkgnd( pDC );
- return TRUE;
- }
- void CExtScrollBar::OnSbPaint( CDC & dc )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtPaintManager::PAINTSCROLLBARDATA _psbd( this );
- _psbd.m_bHelperLightAccent = m_bHelperLightAccent;
- if( _psbd.m_bEnabled )
- {
- _psbd.m_eSBMHT =
- (CExtPaintManager::e_scroll_bar_mouse_hover_type_t)
- m_nSBMHT;
- _psbd.m_bHoveredAreaIsPressed
- = m_bProcessingClick && (! m_bProcessingOutClick );
- } // if( _psbd.m_bEnabled )
-
- PmBridge_GetPM()->ScrollBar_Paint( dc, _psbd );
- }
- void CExtScrollBar::OnPaint()
- {
- if( (! m_bSmoothPainting ) && (! m_bCompleteRepaint ) )
- {
- CScrollBar::OnPaint();
- return;
- } // if( !m_bSmoothPainting )
- CRect rcClient;
- GetClientRect( &rcClient );
- CPaintDC dcPaint( this );
- CExtMemoryDC dc(
- &dcPaint,
- &rcClient
- );
- if( m_bCompleteRepaint )
- {
- if( AnimationClient_StatePaint( dc ) )
- return;
- OnSbPaint( dc );
- } // if( m_bCompleteRepaint )
- else
- DefWindowProc( WM_PAINT, (WPARAM)dc.GetSafeHdc(), 0L );
- }
- void CExtScrollBar::OnSettingChange(UINT uFlags, __EXT_MFC_SAFE_LPCTSTR lpszSection)
- {
- ASSERT_VALID( this );
- CScrollBar::OnSettingChange(uFlags, lpszSection);
- _ScanSysMertics();
- }
- LRESULT CExtScrollBar::OnSizeParent( WPARAM wParam, LPARAM lParam )
- {
- ASSERT_VALID( this );
- if( ! m_bReflectParentSizing )
- return (LRESULT)0;
- wParam;
- DWORD dwWndStyle = CWnd::GetStyle();
- if( (dwWndStyle & WS_VISIBLE) == 0 )
- return 0;
- AFX_SIZEPARENTPARAMS * lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
- ASSERT( lpLayout != NULL );
- CRect rcOwnLayout( lpLayout->rect );
- eScrollerOrientation_t _eSO = GetScrollerOrientation();
- CSize _sizeNeeded( 0, 0 );
- CRect rcWndBeforeSrc( 0, 0, 0, 0 ),
- rcWndBeforeDst( 0, 0, 0, 0 ),
- rcWndAfterSrc( 0, 0, 0, 0 ),
- rcWndAfterDst( 0, 0, 0, 0 );
- bool bHwndBeforeVisible = false, bHwndAfterVisible = false,
- bForceHideBefore = false, bForceHideAfter = false;
- HWND hWndBefore = NULL, hWndAfter = NULL, hWndParent = NULL;
- if( lpLayout->hDWP != NULL )
- {
- if( m_hWndBefore != NULL
- && ::IsWindow( m_hWndBefore )
- )
- {
- bHwndBeforeVisible =
- ( ::__EXT_MFC_GetWindowLong( m_hWndBefore, GWL_STYLE ) & WS_VISIBLE )
- ? true : false;
- if( ! m_bHideHwndBefore )
- {
- ::GetWindowRect( m_hWndBefore, &rcWndBeforeSrc );
- if( hWndParent == NULL )
- {
- hWndParent = ::GetParent( m_hWnd );
- ASSERT( hWndParent != NULL && ::IsWindow(hWndParent) );
- ASSERT( hWndParent == ::GetParent( m_hWndBefore ) );
- } // if( hWndParent == NULL )
- ::ScreenToClient( m_hWndBefore, LPPOINT(&rcWndBeforeSrc) );
- ::ScreenToClient( m_hWndBefore, LPPOINT(&rcWndBeforeSrc) + 1 );
- __EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( m_hWndBefore, GWL_EXSTYLE );
- if( dwExStyle & WS_EX_LAYOUTRTL )
- __EXT_MFC_SwapLeftRight( rcWndBeforeSrc );
- rcWndBeforeDst = rcWndBeforeSrc;
- } // if( !m_bHideHwndBefore )
- hWndBefore = m_hWndBefore;
- }
- if( m_hWndAfter != NULL
- && ::IsWindow( m_hWndAfter )
- )
- {
- bHwndAfterVisible =
- ( ::__EXT_MFC_GetWindowLong( m_hWndAfter, GWL_STYLE ) & WS_VISIBLE )
- ? true : false;
- if( ! m_bHideHwndAfter )
- {
- ::GetWindowRect( m_hWndAfter, &rcWndAfterSrc );
- if( hWndParent == NULL )
- {
- hWndParent = ::GetParent( m_hWnd );
- ASSERT( hWndParent != NULL && ::IsWindow(hWndParent) );
- ASSERT( hWndParent == ::GetParent( m_hWndAfter ) );
- } // if( hWndParent == NULL )
- ::ScreenToClient( m_hWndAfter, LPPOINT(&rcWndAfterSrc) );
- ::ScreenToClient( m_hWndAfter, LPPOINT(&rcWndAfterSrc) + 1 );
- __EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( m_hWndAfter, GWL_EXSTYLE );
- if( dwExStyle & WS_EX_LAYOUTRTL )
- __EXT_MFC_SwapLeftRight( rcWndAfterSrc );
- rcWndAfterDst = rcWndAfterSrc;
- } // if( !m_bHideHwndAfter )
- hWndAfter = m_hWndAfter;
- }
- } // if( lpLayout->hDWP != NULL )
- int nMinExtent;
- switch( _eSO )
- {
- case __ESO_TOP:
- _sizeNeeded.cy = m_nHorzBarHeight;
- lpLayout->rect.top += _sizeNeeded.cy;
- rcOwnLayout.bottom = rcOwnLayout.top + _sizeNeeded.cy;
- lpLayout->sizeTotal.cy += _sizeNeeded.cy;
- if( m_bAutoReserveSpaceBefore )
- rcOwnLayout.left += m_nVertBarWidth;
- if( m_bAutoReserveSpaceAfter )
- rcOwnLayout.right -= m_nVertBarWidth;
- nMinExtent = ::GetSystemMetrics(SM_CXHSCROLL)*2;
- if( hWndAfter != NULL )
- {
- rcWndAfterDst.OffsetRect(
- rcOwnLayout.right - rcWndAfterDst.left - rcWndAfterDst.Width(),
- rcOwnLayout.top - rcWndAfterDst.top
- );
- if( rcWndAfterDst.left <= (rcOwnLayout.left + nMinExtent) )
- bForceHideAfter = true;
- else
- {
- rcWndAfterDst.bottom =
- rcWndAfterDst.top + rcOwnLayout.Height();
- rcOwnLayout.right -= rcWndAfterDst.Width();
- } // if( rcWndAfterDst.left <= (rcOwnLayout.left + nMinExtent) )
- } // if( hWndAfter != NULL )
- if( hWndBefore != NULL )
- {
- rcWndBeforeDst.OffsetRect(
- rcOwnLayout.left - rcWndBeforeDst.left,
- rcOwnLayout.top - rcWndBeforeDst.top
- );
- if( rcWndBeforeDst.right >= (rcOwnLayout.right - nMinExtent) )
- bForceHideBefore = true;
- else
- {
- rcWndBeforeDst.bottom =
- rcWndBeforeDst.top + rcOwnLayout.Height();
- rcOwnLayout.left += rcWndBeforeDst.Width();
- } // else from if( rcWndBeforeDst.right >= (rcOwnLayout.right - nMinExtent) )
- } // if( hWndBefore != NULL )
- break;
- case __ESO_BOTTOM:
- _sizeNeeded.cy = m_nHorzBarHeight;
- lpLayout->rect.bottom -= _sizeNeeded.cy;
- rcOwnLayout.top = rcOwnLayout.bottom - _sizeNeeded.cy;
- lpLayout->sizeTotal.cy += _sizeNeeded.cy;
- if( m_bAutoReserveSpaceBefore )
- rcOwnLayout.left += m_nVertBarWidth;
- if( m_bAutoReserveSpaceAfter )
- rcOwnLayout.right -= m_nVertBarWidth;
- nMinExtent = ::GetSystemMetrics(SM_CXHSCROLL)*2;
- if( hWndAfter != NULL )
- {
- rcWndAfterDst.OffsetRect(
- rcOwnLayout.right - rcWndAfterDst.left - rcWndAfterDst.Width(),
- rcOwnLayout.top - rcWndAfterDst.top
- );
- if( rcWndAfterDst.left <= (rcOwnLayout.left + nMinExtent) )
- bForceHideAfter = true;
- else
- {
- rcWndAfterDst.bottom =
- rcWndAfterDst.top + rcOwnLayout.Height();
- rcOwnLayout.right -= rcWndAfterDst.Width();
- } // if( rcWndAfterDst.left <= (rcOwnLayout.left + nMinExtent) )
- } // if( hWndAfter != NULL )
- if( hWndBefore != NULL )
- {
- rcWndBeforeDst.OffsetRect(
- rcOwnLayout.left - rcWndBeforeDst.left,
- rcOwnLayout.top - rcWndBeforeDst.top
- );
- if( rcWndBeforeDst.right >= (rcOwnLayout.right - nMinExtent) )
- bForceHideBefore = true;
- else
- {
- rcWndBeforeDst.bottom =
- rcWndBeforeDst.top + rcOwnLayout.Height();
- rcOwnLayout.left += rcWndBeforeDst.Width();
- } // else from if( rcWndBeforeDst.right >= (rcOwnLayout.right - nMinExtent) )
- } // if( hWndBefore != NULL )
- break;
- case __ESO_LEFT:
- _sizeNeeded.cx = m_nVertBarWidth;
- lpLayout->rect.left += _sizeNeeded.cx;
- rcOwnLayout.right = rcOwnLayout.left + _sizeNeeded.cx;
- lpLayout->sizeTotal.cx += _sizeNeeded.cx;
- if( m_bAutoReserveSpaceBefore )
- rcOwnLayout.top += m_nHorzBarHeight;
- if( m_bAutoReserveSpaceAfter )
- rcOwnLayout.bottom -= m_nHorzBarHeight;
- break;
- case __ESO_RIGHT:
- _sizeNeeded.cx = m_nVertBarWidth;
- lpLayout->rect.right -= _sizeNeeded.cx;
- rcOwnLayout.left = rcOwnLayout.right - _sizeNeeded.cx;
- lpLayout->sizeTotal.cx += _sizeNeeded.cx;
- if( m_bAutoReserveSpaceBefore )
- rcOwnLayout.top += m_nHorzBarHeight;
- if( m_bAutoReserveSpaceAfter )
- rcOwnLayout.bottom -= m_nHorzBarHeight;
- nMinExtent = ::GetSystemMetrics(SM_CYVSCROLL)*2;
- if( hWndAfter != NULL )
- {
- rcWndAfterDst.OffsetRect(
- rcOwnLayout.left - rcWndAfterDst.left,
- rcOwnLayout.bottom - rcWndAfterDst.top - rcWndAfterDst.Height()
- );
- if( rcWndAfterDst.top <= (rcOwnLayout.top + nMinExtent) )
- bForceHideAfter = true;
- else
- {
- rcWndAfterDst.right =
- rcWndAfterDst.left + rcOwnLayout.Width();
- rcOwnLayout.bottom -= rcWndAfterDst.Height();
- } // if( rcWndAfterDst.top <= (rcOwnLayout.top + nMinExtent) )
- } // if( hWndAfter != NULL )
- if( hWndBefore != NULL )
- {
- rcWndBeforeDst.OffsetRect(
- rcOwnLayout.left - rcWndBeforeDst.left,
- rcOwnLayout.top - rcWndBeforeDst.top
- );
- if( rcWndBeforeDst.bottom >= (rcOwnLayout.bottom - nMinExtent) )
- bForceHideBefore = true;
- else
- {
- rcWndBeforeDst.right =
- rcWndBeforeDst.left + rcOwnLayout.Width();
- rcOwnLayout.top += rcWndBeforeDst.Height();
- } // else from if( rcWndBeforeDst.bottom >= (rcOwnLayout.bottom - nMinExtent) )
- } // if( hWndBefore != NULL )
- break;
- case __ESO_NONE:
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( _eSO )
- // ASSERT( ! rcOwnLayout.IsRectEmpty() );
- if( lpLayout->hDWP != NULL )
- {
- ::AfxRepositionWindow(
- lpLayout,
- m_hWnd,
- &rcOwnLayout
- );
- if( hWndBefore != NULL )
- {
- if( (m_bHideHwndBefore && bHwndBeforeVisible)
- || bForceHideBefore
- )
- lpLayout->hDWP =
- ::DeferWindowPos(
- lpLayout->hDWP,
- hWndBefore, NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_HIDEWINDOW
- );
- else if( rcWndBeforeDst != rcWndBeforeSrc )
- lpLayout->hDWP =
- ::DeferWindowPos(
- lpLayout->hDWP,
- hWndBefore, NULL,
- rcWndBeforeDst.left, rcWndBeforeDst.top,
- rcWndBeforeDst.Width(), rcWndBeforeDst.Height(),
- SWP_NOACTIVATE|SWP_SHOWWINDOW
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- );
- } // if( hWndBefore != NULL )
- if( hWndAfter != NULL )
- {
- if( (m_bHideHwndAfter && bHwndAfterVisible)
- || bForceHideAfter
- )
- lpLayout->hDWP =
- ::DeferWindowPos(
- lpLayout->hDWP,
- hWndAfter, NULL, 0, 0, 0, 0,
- SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- |SWP_HIDEWINDOW
- );
- else if( rcWndAfterDst != rcWndAfterSrc )
- lpLayout->hDWP =
- ::DeferWindowPos(
- lpLayout->hDWP,
- hWndAfter, NULL,
- rcWndAfterDst.left, rcWndAfterDst.top,
- rcWndAfterDst.Width(), rcWndAfterDst.Height(),
- SWP_NOACTIVATE|SWP_SHOWWINDOW
- |SWP_NOZORDER|SWP_NOOWNERZORDER
- );
- } // if( hWndAfter != NULL )
- } // if( lpLayout->hDWP != NULL )
- return 0L;
- }
- void CExtScrollBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- CScrollBar::OnWindowPosChanging( lpwndpos );
- }
- void CExtScrollBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnWindowPosChanged( lpwndpos );
- return;
- }
- AnimationSite_ClientProgressStop( this );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- CRect rcClient;
- GetClientRect( &rcClient );
- AnimationClient_TargetRectSet( rcClient );
- if( (GetStyle()&WS_VISIBLE) == 0 )
- return;
- Invalidate();
- if( ScrollBar_CaptureGet() == m_hWnd )
- UpdateWindow();
- }
- void CExtScrollBar::OnSize(UINT nType, int cx, int cy)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnSize( nType, cx, cy );
- return;
- }
- AnimationSite_ClientProgressStop( this );
- AnimationClient_StateGet( false ).Empty();
- AnimationClient_StateGet( true ).Empty();
- CRect rcClient;
- GetClientRect( &rcClient );
- AnimationClient_TargetRectSet( rcClient );
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- if( (GetStyle()&WS_VISIBLE) == 0 )
- return;
- Invalidate();
- if( ScrollBar_CaptureGet() == m_hWnd )
- UpdateWindow();
- }
- void CExtScrollBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
- {
- ASSERT_VALID( this );
- if( m_bCompleteRepaint )
- return;
- CScrollBar::OnNcCalcSize( bCalcValidRects, lpncsp );
- }
- UINT CExtScrollBar::OnNcHitTest(CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return UINT( CScrollBar::OnNcHitTest( point ) );
- return HTCLIENT;
- }
- int CExtScrollBar::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return CScrollBar::OnMouseActivate( pDesktopWnd, nHitTest, message );
- return m_nMouseActivateCode;
- }
- void CExtScrollBar::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CScrollBar::OnShowWindow( bShow, nStatus);
- if( ! bShow )
- {
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- } // if( ! bShow )
- }
- void CExtScrollBar::OnEnable(BOOL bEnable)
- {
- ASSERT_VALID( this );
- CScrollBar::OnEnable( bEnable );
- if( (! m_bCompleteRepaint )
- || ( GetStyle() & WS_VISIBLE ) == 0
- )
- return;
- if( ! bEnable )
- {
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- } // if( ! bEnable )
- Invalidate();
- if( ScrollBar_CaptureGet() == m_hWnd )
- UpdateWindow();
- }
- void CExtScrollBar::OnCancelMode()
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnCancelMode();
- return;
- }
- if( m_bProcessingCancelMode )
- return;
- m_bProcessingCancelMode = true;
- m_bProcessingClick
- = m_bProcessingOutClick
- = m_bProcessingHover
- = false;
- m_nSBMHT = INT(CExtPaintManager::__ESBMHT_NOWHERE);
- ScrollBar_CaptureRelease();
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- Invalidate();
- ///UpdateWindow();
- m_bProcessingCancelMode = false;
- }
- void CExtScrollBar::OnCaptureChanged(CWnd *pWnd)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnCaptureChanged( pWnd );
- return;
- }
- if( pWnd != this )
- {
- m_bHookCapturedState = false;
- if( pWnd != NULL )
- SendMessage( WM_CANCELMODE );
- }
- else
- m_bHookCapturedState = true;
- }
- BOOL CExtScrollBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return CScrollBar::OnSetCursor( pWnd, nHitTest, message );
- SetCursor( ::LoadCursor( NULL, IDC_ARROW ) );
- return TRUE;
- }
- bool CExtScrollBar::OnHookSpyPreTranslateMessage(
- MSG * pMSG
- )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID( this );
- ASSERT( pMSG != NULL );
- if( pMSG->hwnd == m_hWnd
- && GetSafeHwnd() != NULL
- && ( GetStyle() & WS_VISIBLE ) != 0
- && pMSG->message == WM_TIMER
- && AnimationSite_OnHookTimer( UINT(pMSG->wParam) )
- )
- return true;
- return false;
- }
- bool CExtScrollBar::OnHookSpyMouseMoveMsg(
- MSG * pMSG
- )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID( this );
- ASSERT( pMSG != NULL );
- if( (! m_bEnableHookSpy )
- || ( ! m_bCompleteRepaint )
- || pMSG->hwnd == NULL
- || GetSafeHwnd() == NULL
- )
- return false;
- // if( pMSG->hwnd != m_hWnd
- // && ( ! m_bHookCapturedState )
- // )
- // return false;
- DWORD dwOwnWndStyle = GetStyle();
- if( (dwOwnWndStyle&(WS_VISIBLE|WS_DISABLED)) != WS_VISIBLE )
- return false;
- CPoint ptScreen( -32767, -32767 );
- MSG _msg;
- ::memcpy( &_msg, pMSG, sizeof(MSG) );
- if( pMSG->message == WM_NCMOUSEMOVE )
- {
- _msg.message = WM_MOUSEMOVE;
- _msg.wParam = 0;
- CPoint point( short(LOWORD(DWORD(_msg.lParam))), short(HIWORD(DWORD(_msg.lParam))) );
- ptScreen = point;
- ScreenToClient( &point );
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- }
- else if( pMSG->message == WM_MOUSEMOVE )
- {
- if( _msg.hwnd != m_hWnd )
- {
- CPoint point( short(LOWORD(DWORD(_msg.lParam))), short(HIWORD(DWORD(_msg.lParam))) );
- ::ClientToScreen( _msg.hwnd, &point );
- ptScreen = point;
- ScreenToClient( &point );
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- }
- }
- else
- return false;
- // return ScrollBar_OnMouseMoveMsg( pMSG );
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint == m_hWnd )
- ScrollBar_CaptureSet();
- if( pMSG->hwnd != m_hWnd
- && ( ! m_bHookCapturedState )
- )
- return false;
- WNDPROC pWNDPROC = (WNDPROC) ::__EXT_MFC_GetWindowLong( m_hWnd, __EXT_MFC_GWL_WNDPROC );
- ::CallWindowProc( pWNDPROC, m_hWnd, _msg.message, _msg.wParam, _msg.lParam );
- return true;
- }
- bool CExtScrollBar::OnHookSpyMouseClickMsg(
- MSG * pMSG
- )
- {
- __PROF_UIS_MANAGE_STATE;
- ASSERT_VALID( this );
- ASSERT( pMSG != NULL );
- if( (! m_bEnableHookSpy )
- || ( ! m_bCompleteRepaint )
- || pMSG->hwnd == NULL
- || GetSafeHwnd() == NULL
- )
- return false;
- // if( pMSG->hwnd != m_hWnd
- // && ( ! m_bHookCapturedState )
- // )
- // return false;
- DWORD dwOwnWndStyle = GetStyle();
- if( (dwOwnWndStyle&(WS_VISIBLE|WS_DISABLED)) != WS_VISIBLE )
- return false;
- CPoint ptScreen( -32767, -32767 );
- MSG _msg;
- ::memcpy( &_msg, pMSG, sizeof(MSG) );
- bool bNcTranslate = false;
- switch( _msg.message )
- {
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- if( _msg.hwnd != m_hWnd )
- {
- CPoint point( short(LOWORD(DWORD(_msg.lParam))), short(HIWORD(DWORD(_msg.lParam))) );
- ::ClientToScreen( _msg.hwnd, &point );
- ptScreen = point;
- ScreenToClient( &point );
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- }
- break;
- case WM_NCLBUTTONDOWN:
- _msg.message = WM_LBUTTONDOWN;
- bNcTranslate = true;
- break;
- case WM_NCLBUTTONUP:
- _msg.message = WM_LBUTTONUP;
- bNcTranslate = true;
- break;
- case WM_NCLBUTTONDBLCLK:
- _msg.message = WM_LBUTTONDBLCLK;
- bNcTranslate = true;
- break;
- case WM_NCRBUTTONDOWN:
- _msg.message = WM_RBUTTONDOWN;
- bNcTranslate = true;
- break;
- case WM_NCRBUTTONUP:
- _msg.message = WM_RBUTTONUP;
- bNcTranslate = true;
- break;
- case WM_NCRBUTTONDBLCLK:
- _msg.message = WM_RBUTTONDBLCLK;
- bNcTranslate = true;
- break;
- case WM_NCMBUTTONDOWN:
- _msg.message = WM_MBUTTONDOWN;
- bNcTranslate = true;
- break;
- case WM_NCMBUTTONUP:
- _msg.message = WM_MBUTTONUP;
- bNcTranslate = true;
- break;
- case WM_NCMBUTTONDBLCLK:
- _msg.message = WM_MBUTTONDBLCLK;
- bNcTranslate = true;
- break;
- default:
- return false;
- } //switch( _msg.message )
- if( bNcTranslate )
- {
- _msg.wParam = 0;
- CPoint point( short(LOWORD(DWORD(_msg.lParam))), short(HIWORD(DWORD(_msg.lParam))) );
- ptScreen = point;
- ScreenToClient( &point );
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- } //if( bNcTranslate )
- // return ScrollBar_OnMouseClickMsg( pMSG );
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint == m_hWnd )
- {
- //ScrollBar_CaptureSet();
- m_bHookCapturedState = true;
- }
- else
- // if( pMSG->hwnd != m_hWnd
- // && ( ! m_bHookCapturedState )
- // )
- return false;
- WNDPROC pWNDPROC = (WNDPROC) ::__EXT_MFC_GetWindowLong( m_hWnd, __EXT_MFC_GWL_WNDPROC );
- ::CallWindowProc( pWNDPROC, m_hWnd, _msg.message, _msg.wParam, _msg.lParam );
- return true;
- }
- HWND CExtScrollBar::ScrollBar_CaptureGet() const
- {
- ASSERT_VALID( this );
- if( m_bEnableHookSpy && m_bHookCapturedState )
- return m_hWnd;
- HWND hWndCapture = ::GetCapture();
- return hWndCapture;
- }
- void CExtScrollBar::ScrollBar_CaptureSet()
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() != NULL && ::GetCapture() != m_hWnd )
- {
- m_bHookCapturedState = true;
- if( ! m_bEnableHookSpy )
- ::SetCapture( m_hWnd );
- }
- else
- m_bHookCapturedState = false;
- }
- void CExtScrollBar::ScrollBar_CaptureRelease()
- {
- ASSERT_VALID( this );
- m_bHookCapturedState = false;
- if( ! m_bEnableHookSpy )
- if( GetSafeHwnd() != NULL && ::GetCapture() == m_hWnd )
- ::ReleaseCapture();
- }
- bool CExtScrollBar::ScrollBar_OnMouseMoveMsg(
- MSG * pMSG
- )
- {
- ASSERT_VALID( this );
- ASSERT( pMSG != NULL );
- if( m_bProcessingClick )
- return true;
- CPoint point( short(LOWORD(DWORD(pMSG->lParam))), short(HIWORD(DWORD(pMSG->lParam))) );
- bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
- HWND hWndCapture = ScrollBar_CaptureGet(); // ::GetCapture();
- CExtPopupMenuTipWnd * pATTW = OnAdvancedPopupMenuTipWndGet();
- if( m_bProcessingHover )
- {
- CPoint ptScreen = point;
- ClientToScreen( &ptScreen );
- HWND hWndFromPoint = ::WindowFromPoint( ptScreen );
- if( hWndFromPoint != m_hWnd )
- {
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_HOVERED_STATE_TURNED_OFF
- );
- }
- m_bProcessingHover = false;
- m_nSBMHT = INT(CExtPaintManager::__ESBMHT_NOWHERE);
- if( hWndCapture == m_hWnd )
- SendMessage( WM_CANCELMODE );
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_HOVERED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- if( pATTW != NULL )
- pATTW->Hide();
- Invalidate();
- UpdateWindow();
- return true;
- } // if( hWndFromPoint != m_hWnd )
- CExtPaintManager::PAINTSCROLLBARDATA _psbd( this );
- _psbd.AdjustHT( point );
- if( m_nSBMHT != INT(_psbd.m_eSBMHT) )
- {
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_HOVERED_STATE_TURNED_ON
- );
- }
- m_nSBMHT = INT(_psbd.m_eSBMHT);
-
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_HOVERED_STATE_TURNED_ON
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- Invalidate();
- UpdateWindow();
- } // if( m_nSBMHT != INT(_psbd.m_eSBMHT) )
- if( hWndCapture != m_hWnd )
- ScrollBar_CaptureSet();
- if( pATTW != NULL )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, m_nSBMHT, false );
- return true;
- } // if( m_bProcessingHover )
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_HOVERED_STATE_TURNED_ON
- );
- }
- m_bProcessingHover = true;
- CExtPaintManager::PAINTSCROLLBARDATA _psbd( this );
- _psbd.AdjustHT( point );
- bool bForceRepaint = false;
- if( m_nSBMHT != INT(_psbd.m_eSBMHT) )
- {
- m_nSBMHT = INT(_psbd.m_eSBMHT);
- bForceRepaint = true;
- } // if( m_nSBMHT != INT(_psbd.m_eSBMHT) )
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_HOVERED_STATE_TURNED_ON
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- if( bForceRepaint )
- {
- Invalidate();
- UpdateWindow();
- } // if( bForceRepaint )
- if( hWndCapture != m_hWnd )
- ScrollBar_CaptureSet();
- if( pATTW != NULL )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, m_nSBMHT, false );
- return true;
- }
- bool CExtScrollBar::ScrollBar_OnMouseClickMsg(
- MSG * pMSG
- )
- {
- ASSERT_VALID( this );
- ASSERT( pMSG != NULL );
- switch( pMSG->message )
- {
- case WM_LBUTTONDOWN:
- ScrollBar_TrackMouseLButtonDown( pMSG );
- break;
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- {
- CExtPopupMenuTipWnd * pATTW = OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- }
- break;
- default:
- return false;
- } // switch( pMSG->message )
- if( pMSG->message == WM_RBUTTONDOWN && m_bEnableCtxMenu )
- return false;
- return true;
- }
- void CExtScrollBar::OnMouseMove(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnMouseMove( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_MOUSEMOVE;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseMoveMsg( &_msg );
- }
- void CExtScrollBar::OnLButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnLButtonDown( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_LBUTTONDOWN;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::ScrollBar_TrackMouseLButtonDown(
- MSG * pMSG
- )
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- return;
- CPoint point( short(LOWORD(DWORD(pMSG->lParam))), short(HIWORD(DWORD(pMSG->lParam))) );
- CExtPopupMenuTipWnd * pATTW =
- OnAdvancedPopupMenuTipWndGet();
- CExtPaintManager::PAINTSCROLLBARDATA _psbd( this );
- _psbd.AdjustHT( point );
- if( (! m_bProcessingHover)
- || m_bProcessingClick
- || (! _psbd.m_bEnabled )
- || _psbd.m_eSBMHT == CExtPaintManager::__ESBMHT_NOWHERE
- )
- {
- if( _psbd.m_eSBMHT == CExtPaintManager::__ESBMHT_NOWHERE
- || (! _psbd.m_bEnabled )
- )
- {
- if( pATTW != NULL )
- pATTW->Hide();
- SendMessage( WM_CANCELMODE );
- Invalidate();
- UpdateWindow();
- return;
- }
- }
- if( ! m_bPopupInactiveLightMode )
- ActivateTopParent();
- bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_PRESSED_STATE_TURNED_ON
- );
- }
- if( m_bEnableHookSpy )
- HookSpyUnregister();
- m_nSBMHT = INT(_psbd.m_eSBMHT);
- m_bProcessingClick = m_bProcessingHover = true;
- m_bProcessingOutClick = false;
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_PRESSED_STATE_TURNED_ON
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- Invalidate();
- UpdateWindow();
- if( pATTW != NULL )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, m_nSBMHT, true );
- INT nScrollPosStart = _psbd.m_DSI.nPos, nScrollPos = _psbd.m_DSI.nPos;
- m_nHelperTrackPos = _psbd.m_DSI.nPos;
- m_bHelperHaveTrackPos = true;
- CRect rcArea = _psbd.GetAreaRectHT();
- const UINT nTimerID_zero_start = 401;
- const UINT nTimerID_1st_slow = 402;
- const UINT nTimerEllapse_1st_slow = 400;
- const UINT nTimerID_2nd_fast = 403;
- const UINT nTimerEllapse_2nd_fast = 100;
- HWND hWndOwn = GetSafeHwnd();
- ASSERT( hWndOwn != NULL && ::IsWindow( hWndOwn ) );
- HWND hWndParent = ::GetParent( hWndOwn );
- bool bVirtualMode = false, bFinalNotify = true;
- #if (!defined __EXT_MFC_NO_SCROLLWND)
- CExtScrollWnd * pExtScrollWnd = NULL;
- if( hWndParent != NULL )
- {
- CWnd * pWndParentPermanent = CWnd::FromHandlePermanent( hWndParent );
- if( pWndParentPermanent != NULL )
- {
- pExtScrollWnd =
- DYNAMIC_DOWNCAST(
- CExtScrollWnd,
- pWndParentPermanent
- );
- #if (!defined __EXT_MFC_NO_SCROLLITEMWND)
- if( pExtScrollWnd != NULL )
- {
- CExtScrollItemWnd * pExtScrollItemWnd =
- DYNAMIC_DOWNCAST(
- CExtScrollItemWnd,
- pWndParentPermanent
- );
- if( pExtScrollItemWnd != NULL )
- {
- DWORD dwScrollType = __ESIW_ST_NONE;
- if( _psbd.m_bHorzBar )
- dwScrollType = pExtScrollItemWnd->SiwScrollTypeHGet();
- else
- dwScrollType = pExtScrollItemWnd->SiwScrollTypeVGet();
- if( dwScrollType == __ESIW_ST_VIRTUAL )
- bVirtualMode = true;
- } // if( pExtScrollItemWnd != NULL )
- } // if( pExtScrollWnd != NULL )
- #endif // (!defined __EXT_MFC_NO_SCROLLITEMWND)
- } // if( pWndParentPermanent != NULL )
- } // if( hWndParent != NULL )
- #endif // (!defined __EXT_MFC_NO_SCROLLWND)
- bool bStopFlag = false;
- CPoint ptCursor( point );
- INT nStepSize = 0L;
- bool bUpStep = false;
- bool bMouseButtonsNotSwapped = ( ::GetSystemMetrics( SM_SWAPBUTTON ) != 0 ) ? false : true;
- switch( _psbd.m_eSBMHT )
- {
- case CExtPaintManager::__ESBMHT_BUTTON_UP:
- bUpStep = true;
- // continue falling here ...
- case CExtPaintManager::__ESBMHT_BUTTON_DOWN:
- nStepSize = GetStepSize(); // nStepSize = 1L;
- #if (!defined __EXT_MFC_NO_SCROLLWND)
- if( pExtScrollWnd != NULL )
- {
- int nDir = ( _psbd.m_eSBMHT == CExtPaintManager::__ESBMHT_BUTTON_DOWN ) ? (+1) : (-1);
- CSize _size = pExtScrollWnd->OnSwGetLineSize( nDir );
- nStepSize = _psbd.m_bHorzBar ? _size.cx : _size.cy;
- if( nStepSize <= 0L )
- nStepSize = GetStepSize(); // nStepSize = 1L;
- }
- #endif // (!defined __EXT_MFC_NO_SCROLLWND)
- break;
- case CExtPaintManager::__ESBMHT_PAGE_UP:
- bUpStep = true;
- // continue falling here ...
- case CExtPaintManager::__ESBMHT_PAGE_DOWN:
- nStepSize = (INT)_psbd.m_DSI.nPage;
- #if (!defined __EXT_MFC_NO_SCROLLWND)
- if( pExtScrollWnd != NULL )
- {
- int nDir = ( _psbd.m_eSBMHT == CExtPaintManager::__ESBMHT_PAGE_DOWN ) ? (+1) : (-1);
- CSize _size = pExtScrollWnd->OnSwGetPageSize( nDir );
- nStepSize = _psbd.m_bHorzBar ? _size.cx : _size.cy;
- }
- #endif // (!defined __EXT_MFC_NO_SCROLLWND)
- if( nStepSize <= 0L )
- nStepSize = GetStepSize(); // nStepSize = 1L;
- break;
- case CExtPaintManager::__ESBMHT_THUMB:
- break;
- } // switch( _psbd.m_eSBMHT )
- bool bMenuMode = false;
- if( CExtPopupMenuWnd::IsMenuTracking() )
- {
- // CExtPopupMenuWnd * pPopup = CExtPopupMenuSite::g_DefPopupMenuSite.GetInstance();
- // if( pPopup != NULL )
- // {
- // CWnd * pWnd = GetParent();
- // for( ; pWnd != NULL; pWnd = pWnd->GetParent() )
- // {
- // if( pWnd == pPopup )
- // {
- // bMenuMode = true;
- // break;
- // } // if( pWnd == pPopup )
- // } // for( ; pWnd != NULL; pWnd = pWnd->GetParent() )
- // } // if( pPopup != NULL )
- CWnd * pWnd = GetParent();
- for( ; pWnd != NULL; pWnd = pWnd->GetParent() )
- {
- if( pWnd->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- {
- bMenuMode = true;
- break;
- } // if( pWnd == pPopup )
- if( (pWnd->GetStyle()&WS_CHILD) == 0 )
- break;
- } // for( ; pWnd != NULL; pWnd = pWnd->GetParent() )
- } // if( CExtPopupMenuWnd::IsMenuTracking() )
- INT nMx = INT( _psbd.m_DSI.nMax - _psbd.m_DSI.nPage + 1 );
- INT nScrollLimit =
- _psbd.m_DSI.nMax
- - _psbd.m_DSI.nMin
- - _psbd.m_DSI.nPage
- + 1
- ;
- ASSERT( nScrollLimit >= 0 );
- if( nStepSize > nScrollLimit )
- nStepSize = nScrollLimit;
- CRect rcScrollable = _psbd.m_rcBar;
- if( _psbd.m_bHorzBar )
- {
- rcScrollable.left = _psbd.m_rcButtonUp.right;
- rcScrollable.right = _psbd.m_rcButtonDown.left;
- }
- else
- {
- rcScrollable.top = _psbd.m_rcButtonUp.bottom;
- rcScrollable.bottom = _psbd.m_rcButtonDown.top;
- }
- ScrollBar_CaptureSet(); //::SetCapture( hWndOwn );
- if( nStepSize != 0L )
- {
- ::PostMessage( hWndOwn, WM_TIMER, WPARAM(nTimerID_zero_start), LPARAM(0L) );
- //::SetTimer( hWndOwn, nTimerID_1st_slow, nTimerEllapse_1st_slow, NULL );
- }
- for( MSG msg; ::IsWindow( hWndOwn ) && (!bStopFlag); )
- {
- if( ! PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- {
- if( ! ::IsWindow( hWndOwn ) )
- break;
- ::WaitMessage();
- continue;
- } // if( !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- bool bAnalyzeThumb = false;
- switch( msg.message )
- {
- case WM_LBUTTONDBLCLK:
- case WM_LBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_CANCELMODE:
- case WM_ACTIVATEAPP:
- case WM_KEYDOWN:
- case WM_KEYUP:
- bStopFlag = true;
- break;
- case WM_CAPTURECHANGED:
- if( (HWND)msg.wParam != hWndOwn )
- bStopFlag = true;
- break;
- case WM_MOUSEMOVE:
- if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_THUMB) )
- {
- if( ( ! CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_LBUTTON : VK_RBUTTON,true) )
- || CExtPopupMenuWnd::IsKeyPressed( VK_MBUTTON )
- || CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_RBUTTON : VK_LBUTTON,true )
- || ( (!bMenuMode) && CExtPopupMenuWnd::IsMenuTracking() )
- )
- {
- bStopFlag = true;
- break;
- }
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- bAnalyzeThumb = true;
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWndOwn, &ptCursor );
- break;
- } // if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_THUMB) )
- if( nStepSize == 0 )
- break;
- case WM_TIMER:
- {
- if( ( ! CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_LBUTTON : VK_RBUTTON,true) )
- || CExtPopupMenuWnd::IsKeyPressed( VK_MBUTTON )
- || CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_RBUTTON : VK_LBUTTON,true )
- || ( (!bMenuMode) && CExtPopupMenuWnd::IsMenuTracking() )
- )
- {
- bStopFlag = true;
- break;
- }
- if( msg.hwnd != hWndOwn )
- break;
- if( msg.wParam != nTimerID_zero_start
- && msg.wParam != nTimerID_1st_slow
- && msg.wParam != nTimerID_2nd_fast
- )
- break;
- if( msg.wParam == nTimerID_zero_start )
- ::SetTimer( hWndOwn, nTimerID_1st_slow, nTimerEllapse_1st_slow, NULL );
- else if( msg.wParam == nTimerID_1st_slow )
- {
- ::KillTimer( hWndOwn, nTimerID_1st_slow );
- CExtPaintManager::stat_PassPaintMessages();
- ::SetTimer( hWndOwn, nTimerID_2nd_fast, nTimerEllapse_2nd_fast, NULL );
- }
- ASSERT( nStepSize != 0L );
- PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWndOwn, &ptCursor );
- bool bPause = false;
- if( ! rcArea.PtInRect( ptCursor ) )
- bPause = true;
- else
- {
- if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_UP)
- || m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_DOWN)
- )
- { // update changed area rect (page up/down cases)
- CExtPaintManager::PAINTSCROLLBARDATA _psbd2( this );
- _psbd2.AdjustHT( ptCursor );
- INT nSBMHT2 = INT( _psbd.m_eSBMHT );
- if( nSBMHT2 != m_nSBMHT )
- bPause = true;
- else
- {
- CRect rcArea2 = _psbd2.GetAreaRectHT();
- if( ! rcArea2.PtInRect( ptCursor ) )
- bPause = true;
- else
- {
- if( _psbd2.m_bHorzBar )
- {
- if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_UP) )
- {
- if( ptCursor.x >= _psbd2.m_rcThumb.left )
- bPause = true;
- }
- else if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_DOWN) )
- {
- if( ptCursor.x <= _psbd2.m_rcThumb.right )
- bPause = true;
- }
- }
- else
- {
- if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_UP) )
- {
- if( ptCursor.y >= _psbd2.m_rcThumb.top )
- bPause = true;
- }
- else if( m_nSBMHT == INT(CExtPaintManager::__ESBMHT_PAGE_DOWN) )
- {
- if( ptCursor.y <= _psbd2.m_rcThumb.bottom )
- bPause = true;
- }
- }
- }
- }
- } // update changed area rect (page up/down cases)
- }
- if( bPause )
- {
- if( ! m_bProcessingOutClick )
- {
- m_bProcessingOutClick = true;
- Invalidate();
- }
- if( pATTW != NULL )
- pATTW->Hide();
- continue;
- }
- if( bUpStep )
- {
- nScrollPos -= nStepSize;
- if( nScrollPos < _psbd.m_DSI.nMin )
- nScrollPos = _psbd.m_DSI.nMin;
- } // if( bUpStep )
- else
- {
- nScrollPos += nStepSize;
- if( nScrollPos > nMx )
- nScrollPos = nMx;
- } // else from if( bUpStep )
- if( m_bSendEqualNotifications || _GetScrollPos( true ) != nScrollPos )
- {
- bool bSendScrollingNotification = true, bTrackPos = true;
- if( hWndParent != NULL )
- {
- switch( m_nSBMHT )
- {
- case (CExtPaintManager::__ESBMHT_BUTTON_UP):
- // bSendScrollingNotification = false;
- if( m_bSendActionNotifications )
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM(
- ( _psbd.m_bHorzBar ? SB_LINELEFT : SB_LINEUP ),
- 0
- ),
- LPARAM(m_hWnd)
- );
- if( ! bVirtualMode )
- _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- else
- bFinalNotify = (!m_bSendActionNotifications); // false;
- break;
- case (CExtPaintManager::__ESBMHT_BUTTON_DOWN):
- // bSendScrollingNotification = false;
- if( m_bSendActionNotifications )
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM(
- ( _psbd.m_bHorzBar ? SB_LINERIGHT : SB_LINEDOWN ),
- 0
- ),
- LPARAM(m_hWnd)
- );
- if( ! bVirtualMode )
- _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- else
- bFinalNotify = (!m_bSendActionNotifications); // false;
- break;
- case (CExtPaintManager::__ESBMHT_PAGE_UP):
- // bSendScrollingNotification = false;
- if( m_bSendActionNotifications )
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM(
- ( _psbd.m_bHorzBar ? SB_PAGELEFT : SB_PAGEUP ),
- 0
- ),
- LPARAM(m_hWnd)
- );
- if( ! bVirtualMode )
- _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- else
- bFinalNotify = (!m_bSendActionNotifications); // false;
- break;
- case (CExtPaintManager::__ESBMHT_PAGE_DOWN):
- // bSendScrollingNotification = false;
- if( m_bSendActionNotifications )
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM(
- ( _psbd.m_bHorzBar ? SB_PAGERIGHT : SB_PAGEDOWN ),
- 0
- ),
- LPARAM(m_hWnd)
- );
- if( ! bVirtualMode )
- _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- else
- bFinalNotify = (!m_bSendActionNotifications); // false;
- break;
- case (CExtPaintManager::__ESBMHT_THUMB):
- bTrackPos = true;
- if( ! bVirtualMode )
- _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- else
- bFinalNotify = false; // (!m_bSendActionNotifications); // false;
- break;
- } // switch( m_nSBMHT )
- } // if( hWndParent != NULL )
- // if( ! bVirtualMode )
- // _SetScrollPos( nScrollPos, bTrackPos, true, bSendScrollingNotification );
- // else
- // bFinalNotify = false;
- if( pATTW != NULL && ( ! bAnalyzeThumb ) )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, m_nSBMHT, true );
- } // if( m_bSendEqualNotifications || _GetScrollPos( true ) != nScrollPos )
- CExtPaintManager::PAINTSCROLLBARDATA _psbd2( this );
- ::memcpy( &_psbd.m_DSI, &_psbd2.m_DSI, sizeof(SCROLLINFO) );
- nMx = INT( _psbd.m_DSI.nMax - _psbd.m_DSI.nPage + 1 );
- nScrollLimit =
- _psbd.m_DSI.nMax
- - _psbd.m_DSI.nMin
- - _psbd.m_DSI.nPage
- + 1
- ;
- ASSERT( nScrollLimit >= 0 );
- if( nStepSize > nScrollLimit )
- nStepSize = nScrollLimit;
- _psbd.AdjustHT( ptCursor );
- bool bProcessingOutClick =
- ( m_nSBMHT == INT(_psbd.m_eSBMHT) )
- ? false : true;
- rcArea = _psbd.GetAreaRect( CExtPaintManager::e_scroll_bar_mouse_hover_type_t(m_nSBMHT) );
- if( m_bProcessingOutClick != bProcessingOutClick )
- {
- bool bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- // if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- }
- m_bProcessingOutClick = bProcessingOutClick;
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- Invalidate();
- UpdateWindow();
- }
- }
- break;
- default:
- {
- if( ( ! CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_LBUTTON : VK_RBUTTON,true) )
- || CExtPopupMenuWnd::IsKeyPressed( VK_MBUTTON )
- || CExtPopupMenuWnd::IsKeyPressed( bMouseButtonsNotSwapped ? VK_RBUTTON : VK_LBUTTON,true )
- || ( (!bMenuMode) && CExtPopupMenuWnd::IsMenuTracking() )
- )
- bStopFlag = true;
- }
- break;
- } // switch( msg.message )
- if( ! ::IsWindow( hWndOwn ) )
- bStopFlag = true;
- if( bStopFlag || nScrollLimit == 0L )
- break;
- if( bAnalyzeThumb )
- {
- LONG nPixelOffset = _psbd.m_bHorzBar
- ? (ptCursor.x - point.x)
- : (ptCursor.y - point.y);
- LONG nPixelExtent = _psbd.m_bHorzBar
- ? (rcScrollable.Width() - _psbd.m_rcThumb.Width())
- : (rcScrollable.Height() - _psbd.m_rcThumb.Height());
- if( nPixelExtent <= 0 )
- {
- bStopFlag = true;
- break;
- } // if( nPixelExtent <= 0 )
- if( abs(nPixelOffset) > nPixelExtent )
- nPixelOffset =
- (nPixelOffset < 0)
- ? (-nPixelExtent)
- : nPixelExtent;
- INT nShift =
- ( nPixelExtent == 0 || nPixelOffset == 0 )
- ? 0
- : ::MulDiv( nScrollLimit, abs(nPixelOffset), nPixelExtent );
- nScrollPos = nScrollPosStart;
- if( nPixelOffset < 0 )
- {
- nScrollPos -= nShift;
- if( nScrollPos < _psbd.m_DSI.nMin )
- nScrollPos = _psbd.m_DSI.nMin;
- } // if( nPixelOffset < 0 )
- else
- {
- nScrollPos += nShift;
- if( nScrollPos > nMx )
- nScrollPos = nMx;
- } // else from if( nPixelOffset < 0 )
- if( (! bVirtualMode )
- // || nScrollPos == _psbd.m_DSI.nMin
- // || nScrollPos >= _psbd.m_DSI.nMax-200000
- )
- {
- if( m_bSendEqualNotifications || _GetScrollPos( true ) != nScrollPos )
- {
- _SetScrollPos( nScrollPos, true );
- if( pATTW != NULL )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, m_nSBMHT, true );
- } // if( m_bSendEqualNotifications || _GetScrollPos( true ) != nScrollPos )
- bFinalNotify = true;
- }
- CExtPaintManager::PAINTSCROLLBARDATA _psbd2( this );
- ::memcpy( &_psbd.m_DSI, &_psbd2.m_DSI, sizeof(SCROLLINFO) );
- nMx = INT( _psbd.m_DSI.nMax - _psbd.m_DSI.nPage + 1 );
- nScrollLimit =
- _psbd.m_DSI.nMax
- - _psbd.m_DSI.nMin
- - _psbd.m_DSI.nPage
- + 1
- ;
- ASSERT( nScrollLimit >= 0 );
- if( nStepSize > nScrollLimit )
- nStepSize = nScrollLimit;
- _psbd.AdjustHT( ptCursor );
- // bool bProcessingOutClick =
- // ( m_nSBMHT == INT(_psbd.m_eSBMHT) )
- // ? false : true;
- rcArea = _psbd.GetAreaRect( CExtPaintManager::__ESBMHT_THUMB );
- // if( m_bProcessingOutClick != bProcessingOutClick )
- // {
- // m_bProcessingOutClick = bProcessingOutClick;
- // Invalidate();
- // UpdateWindow();
- // }
- continue;
- } // if( bAnalyzeThumb )
- if( m_bPopupInactiveLightMode
- && ( msg.message == WM_TIMER
- || (__EXT_MFC_WM_MOUSEFIRST <= msg.message && msg.message <= __EXT_MFC_WM_MOUSELAST )
- )
- )
- ::PeekMessage(&msg,NULL,msg.message,msg.message,PM_REMOVE);
- else
- if( ! AfxGetThread()->PumpMessage() )
- break;
- } // for( MSG msg; ::IsWindow( hWndOwn ) && (!bStopFlag); )
- if( ! ::IsWindow( hWndOwn ) )
- return;
- if( nStepSize != 0L )
- {
- ::KillTimer( hWndOwn, nTimerID_1st_slow );
- ::KillTimer( hWndOwn, nTimerID_2nd_fast );
- }
- bAnimationLocked = AnimationClient_CacheGeneratorIsLocked();
- if( ! bAnimationLocked )
- {
- AnimationClient_CacheGeneratorLock();
- if( AnimationClient_StateGet(true).IsEmpty() )
- AnimationClient_CacheNextStateMinInfo(
- false,
- __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- }
- // if( nScrollPos > INT(_psbd.m_DSI.nMax-_psbd.m_DSI.nMin-_psbd.m_DSI.nPage) )
- // nScrollPos = INT(_psbd.m_DSI.nMax-_psbd.m_DSI.nMin-_psbd.m_DSI.nPage);
- if( bFinalNotify
- // && _GetScrollPos( false ) != nScrollPos
- )
- {
- bool bSendScrollingNotification = true;
- // switch( m_nSBMHT )
- // {
- // case (CExtPaintManager::__ESBMHT_BUTTON_UP):
- // case (CExtPaintManager::__ESBMHT_BUTTON_DOWN):
- // case (CExtPaintManager::__ESBMHT_PAGE_UP):
- // case (CExtPaintManager::__ESBMHT_PAGE_DOWN):
- // bSendScrollingNotification = false;
- // break;
- // }
- // _SetScrollPos( nScrollPos, true, false, bSendScrollingNotification );
- _SetScrollPos( nScrollPos, false, true, bSendScrollingNotification );
- }
- m_nSBMHT = INT(CExtPaintManager::__ESBMHT_NOWHERE);
- m_bProcessingClick
- = m_bProcessingOutClick
- = m_bProcessingHover
- = false;
- if( ! bAnimationLocked )
- {
- ::GetCursorPos( &ptCursor );
- ScreenToClient( &ptCursor );
- _psbd.AdjustHT( ptCursor );
- m_nSBMHT = INT(_psbd.m_eSBMHT);
- AnimationClient_CacheNextStateMinInfo(
- true,
- __EAPT_BY_PRESSED_STATE_TURNED_OFF
- );
- AnimationClient_CacheGeneratorUnlock();
- }
- Invalidate();
- UpdateWindow();
- m_nHelperTrackPos = -1;
- m_bHelperHaveTrackPos = false;
- // if( ::GetCapture() == hWndOwn )
- // ::ReleaseCapture();
- ScrollBar_CaptureRelease();
- if( pATTW != NULL )
- OnAdvancedPopupMenuTipWndDisplay( *pATTW, INT(_psbd.m_eSBMHT), false );
- ::SendMessage(
- hWndParent,
- _psbd.m_bHorzBar ? WM_HSCROLL : WM_VSCROLL,
- MAKEWPARAM( SB_ENDSCROLL, 0 ), // MAKEWPARAM( SB_ENDSCROLL, nPos ),
- LPARAM(m_hWnd)
- );
- if( m_bEnableHookSpy )
- HookSpyRegister( __EHSEF_MOUSE_ALL_WITHOUT_WHEEL|__EHSEF_WND_PROC_IN|__EHSEF_PRE_TRANSLATION );
- }
- void CExtScrollBar::OnLButtonUp(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnLButtonUp( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_LBUTTONUP;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnLButtonDblClk( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_LBUTTONDOWN; // WM_LBUTTONDBLCLK;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnMButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnMButtonDown( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_MBUTTONDOWN;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnMButtonUp(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnMButtonUp( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_MBUTTONUP;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnMButtonDblClk(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnMButtonDblClk( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_MBUTTONDBLCLK;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnRButtonDown(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnRButtonDown( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_RBUTTONDOWN;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- if( ScrollBar_OnMouseClickMsg( &_msg ) )
- return;
- if( ! m_bEnableCtxMenu )
- return;
- CExtPopupMenuTipWnd * pATTW = OnAdvancedPopupMenuTipWndGet();
- if( pATTW != NULL )
- pATTW->Hide();
- m_ptCtxMenuCache = point;
- CPoint ptScreen = point;
- ClientToScreen( &ptScreen );
- SendMessage( WM_CONTEXTMENU, WPARAM(m_hWnd), MAKELPARAM(ptScreen.x,ptScreen.y) );
- }
- void CExtScrollBar::OnRButtonUp(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnRButtonUp( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_RBUTTONUP;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnRButtonDblClk(UINT nFlags, CPoint point)
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnRButtonDblClk( nFlags, point );
- return;
- }
- MSG _msg;
- ::memset( &_msg, 0, sizeof(MSG) );
- _msg.hwnd = m_hWnd;
- _msg.message = WM_RBUTTONDBLCLK;
- _msg.wParam = WPARAM(nFlags);
- _msg.lParam = MAKELPARAM( point.x ,point.y );
- ScrollBar_OnMouseClickMsg( &_msg );
- }
- void CExtScrollBar::OnTimer(__EXT_MFC_UINT_PTR nIDEvent)
- {
- ASSERT_VALID( this );
- if( AnimationSite_OnHookTimer( UINT(nIDEvent) ) )
- return;
- CScrollBar::OnTimer( nIDEvent );
- }
- void CExtScrollBar::OnContextMenu( CWnd * pWnd, CPoint point )
- {
- ASSERT_VALID( this );
- if( ! m_bCompleteRepaint )
- {
- CScrollBar::OnContextMenu( pWnd, point );
- return;
- }
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- if( CExtPopupMenuWnd::IsMenuTracking() )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- {
- TCHAR strClassName[ 512 ];
- ::memset( strClassName, 0, sizeof(strClassName) );
- ::GetClassName( hWndScrollingTarget, strClassName, 512 );
- if( _tcslen( strClassName ) > 0 )
- {
- __EXT_MFC_STRLWR( strClassName, 512 );
- if( _tcscmp( strClassName, _T("combolbox") ) == 0 )
- {
- //__EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( hWndScrollingTarget, GWL_STYLE );
- //if( ( dwWndStyle & WS_CHILD ) == 0 )
- return;
- }
- }
- }
- }
- bool bVert = ( ( dwStyle & SBS_VERT ) != 0 ) ? true : false;
- HWND hWndOwn = m_hWnd;
- HWND hWndFocus = ::GetFocus();
- if( hWndFocus == NULL )
- {
- hWndFocus = ::GetParent( m_hWnd );
- if( hWndFocus == NULL )
- hWndFocus = hWndOwn;
- ::SetFocus( hWndFocus );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- }
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- if( pPopup == NULL )
- return;
- if( ! pPopup->CreatePopupMenu( hWndOwn ) )
- {
- ASSERT( FALSE );
- return;
- }
- CExtSafeString strMenuItemText;
- strMenuItemText = _T("Scroll Here");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_HERE, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- VERIFY( pPopup->ItemInsert() );
- if( bVert )
- {
- strMenuItemText = _T("Top");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_EDGE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Bottom");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_EDGE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- VERIFY( pPopup->ItemInsert() );
- strMenuItemText = _T("Page Up");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_PAGE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Page Down");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_PAGE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- VERIFY( pPopup->ItemInsert() );
- strMenuItemText = _T("Scroll Up");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_LINE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Scroll Down");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_LINE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- } // if( bVert )
- else
- {
- strMenuItemText = _T("Left Edge");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_EDGE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Right Edge");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_EDGE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- VERIFY( pPopup->ItemInsert() );
- strMenuItemText = _T("Page Left");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_PAGE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Page Right");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_PAGE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- VERIFY( pPopup->ItemInsert() );
- strMenuItemText = _T("Scroll Left");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_LINE_LOWER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- strMenuItemText = _T("Scroll Right");
- VERIFY( pPopup->ItemInsertCommand( __EXT_ID_SCROLL_LINE_UPPER, -1, LPCTSTR(strMenuItemText), NULL, NULL, false, 0, hWndOwn ) );
- } // else from if( bVert )
- if( ! pPopup->TrackPopupMenu( TPMX_NO_CMD_UI|TPMX_NO_HIDE_RARELY|TPMX_HIDE_KEYBOARD_ACCELERATORS, point.x, point.y ) )
- {
- delete pPopup;
- ASSERT( FALSE );
- return;
- }
- }
- void CExtScrollBar::OnScrollHere()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- bool bVert = ( ( dwStyle & SBS_VERT ) != 0 ) ? true : false;
- CRect rcClient;
- GetClientRect( &rcClient );
- INT nPosOld = INT( GetScrollPos() );
- INT nPosNew = nPosOld;
- if( bVert )
- {
- INT nHeight = INT( rcClient.Height() - m_nHorzBarHeight * 2 );
- if( nHeight <= 1 )
- return;
- nPosNew = (INT) ::MulDiv( nRange, m_ptCtxMenuCache.y - m_nHorzBarHeight, nHeight ) + scrollInfo.nMin;
- } // if( bVert )
- else
- {
- INT nWidth = INT( rcClient.Width() - m_nVertBarWidth * 2 );
- if( nWidth <= 1 )
- return;
- nPosNew = (INT) ::MulDiv( nRange, m_ptCtxMenuCache.x - m_nVertBarWidth, nWidth ) + scrollInfo.nMin;
- } // else from if( bVert )
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollEdgeLower()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nPosOld = INT( GetScrollPos() ), nPosNew = scrollInfo.nMin;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollEdgeUpper()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nPosOld = INT( GetScrollPos() ), nPosNew = scrollInfo.nMax;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollLineLower()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nStepSize = max( m_nStepSize, 1 );
- INT nPosOld = INT( GetScrollPos() );
- INT nPosNew = nPosOld - nStepSize;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollLineUpper()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nStepSize = max( m_nStepSize, 1 );
- INT nPosOld = INT( GetScrollPos() );
- INT nPosNew = nPosOld + nStepSize;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollPageLower()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nPosOld = INT( GetScrollPos() );
- INT nPosNew = nPosOld - scrollInfo.nPage;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- void CExtScrollBar::OnScrollPageUpper()
- {
- ASSERT_VALID( this );
- if( ! m_bEnableCtxMenu )
- return;
- DWORD dwStyle = GetStyle();
- if( ( dwStyle & SBS_SIZEBOX ) != 0 )
- return;
- SCROLLINFO scrollInfo;
- ::memset( &scrollInfo, 0, sizeof(SCROLLINFO) );
- scrollInfo.cbSize = sizeof( SCROLLINFO );
- scrollInfo.fMask = SIF_ALL;
- if( ! GetScrollInfo( &scrollInfo ) )
- return;
- INT nRange = scrollInfo.nMax - scrollInfo.nMin;
- if( nRange <= 0 || nRange <= INT(scrollInfo.nPage) )
- return;
- INT nPosOld = INT( GetScrollPos() );
- INT nPosNew = nPosOld + scrollInfo.nPage;
- nPosNew = max( nPosNew, scrollInfo.nMin );
- nPosNew = min( nPosNew, scrollInfo.nMax );
- if( nPosOld != nPosNew )
- {
- HWND hWndInvalidate = ::GetParent( m_hWnd ), hWndOwn = m_hWnd;
- _SetScrollPos( nPosNew );
- if( ! ::IsWindow( hWndOwn ) )
- return;
- CExtNCSB_ScrollContainer * pScrollContainer = _GetParentScrollContainer();
- if( pScrollContainer != NULL )
- {
- HWND hWndScrollingTarget = pScrollContainer->GetSafeScrollingTargetHWND();
- if( hWndScrollingTarget != NULL && ::IsWindow( hWndScrollingTarget ) )
- hWndInvalidate = hWndScrollingTarget;
- }
- if( hWndInvalidate != NULL )
- {
- ::InvalidateRect( hWndInvalidate, NULL, TRUE );
- ::UpdateWindow( hWndInvalidate );
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtZoomScrollBar
- IMPLEMENT_DYNCREATE( CExtZoomScrollBar, CExtScrollBar );
- CExtZoomScrollBar::CExtZoomScrollBar()
- {
- }
- CExtZoomScrollBar::~CExtZoomScrollBar()
- {
- }
- BEGIN_MESSAGE_MAP(CExtZoomScrollBar, CExtScrollBar)
- //{{AFX_MSG_MAP(CExtZoomScrollBar)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // class CExtNCSB_ScrollContainer
- IMPLEMENT_DYNAMIC( CExtNCSB_ScrollContainer, CWnd );
- CExtNCSB_ScrollContainer::CExtNCSB_ScrollContainer(
- HWND hWndScrollingTaget,
- CExtNCSB_ScrollContainer::e_mode_t eMode
- )
- : m_hWndScrollingTaget( hWndScrollingTaget )
- , m_eMode( eMode )
- , m_pWndScrollBar( NULL )
- {
- ASSERT( m_hWndScrollingTaget != NULL && ::IsWindow( m_hWndScrollingTaget ) );
- ASSERT( INT(__EM_MIN_VALUE) <= INT(m_eMode) && INT(m_eMode) <= INT(__EM_MAX_VALUE) );
- }
- CExtNCSB_ScrollContainer::~CExtNCSB_ScrollContainer()
- {
- }
- CExtScrollBar * CExtNCSB_ScrollContainer::GetScrollBarInContainer() const
- {
- ASSERT_VALID( this );
- return m_pWndScrollBar;
- }
- CExtNCSB_ScrollContainer::e_mode_t CExtNCSB_ScrollContainer::GetMode() const
- {
- ASSERT_VALID( this );
- ASSERT( INT(__EM_MIN_VALUE) <= INT(m_eMode) && INT(m_eMode) <= INT(__EM_MAX_VALUE) );
- return m_eMode;
- }
- HWND CExtNCSB_ScrollContainer::GetSafeScrollingTargetHWND() const
- {
- ASSERT_VALID( this );
- // if( GetSafeHwnd() == NULL )
- // return NULL;
- if( m_hWndScrollingTaget == NULL || (! ::IsWindow( m_hWndScrollingTaget ) ) )
- return NULL;
- return m_hWndScrollingTaget;
- }
- CExtScrollBar * CExtNCSB_ScrollContainer::OnInstantiateAndCreateScrollBar( bool bChildMode )
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return NULL;
- e_mode_t eMode = GetMode();
- if( ! ( eMode == __EM_HORIZONTAL_SCROLL_BAR || eMode == __EM_VERTICAL_SCROLL_BAR ) )
- return NULL;
- CExtScrollBar * pWndScrollBar = NULL;
- try
- {
- pWndScrollBar = new CExtScrollBar;
- pWndScrollBar->m_bAlwaysSendThumbButtonNotifications = true;
- pWndScrollBar->m_bSendActionNotifications = false;
- if( ! bChildMode )
- {
- pWndScrollBar->m_bPopupInactiveLightMode = true;
- pWndScrollBar->m_bEnableHookSpy = true;
- pWndScrollBar->m_nMouseActivateCode = MA_NOACTIVATE;
- }
- CRect rc;
- GetClientRect( &rc );
- if( ! pWndScrollBar->Create(
- WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS
- | ( ( eMode == __EM_HORIZONTAL_SCROLL_BAR ) ? SBS_HORZ : SBS_VERT )
- ,
- rc,
- this,
- UINT(__EXT_MFC_IDC_STATIC)
- )
- )
- return NULL;
- return pWndScrollBar;
- }
- catch( CException * pException )
- {
- pException->Delete();
- }
- catch( ... )
- {
- }
- if( pWndScrollBar != NULL )
- delete pWndScrollBar;
- return NULL;
- }
- bool CExtNCSB_ScrollContainer::Create( CWnd * pWndParent )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pWndParent );
- ASSERT( pWndParent->GetSafeHwnd() != NULL );
- HWND hWndScrollingTaget = GetSafeScrollingTargetHWND();
- if( hWndScrollingTaget == NULL || (! ::IsWindow( hWndScrollingTaget ) ) )
- return false;
- WNDCLASS _wndClassInfo;
- HINSTANCE hInst = ::AfxGetInstanceHandle();
- if( ! ::GetClassInfo( hInst, __EXT_NCSB_SCROLL_CONTAINER_CLASS_NAME, &_wndClassInfo ) )
- {
- _wndClassInfo.style = CS_GLOBALCLASS|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;
- _wndClassInfo.lpfnWndProc = ::DefWindowProc;
- _wndClassInfo.cbClsExtra = _wndClassInfo.cbWndExtra = 0;
- _wndClassInfo.hInstance = hInst;
- _wndClassInfo.hIcon = NULL;
- _wndClassInfo.hCursor = ::LoadCursor( NULL, IDC_ARROW );
- ASSERT( _wndClassInfo.hCursor != NULL );
- _wndClassInfo.hbrBackground = NULL;
- _wndClassInfo.lpszMenuName = NULL;
- _wndClassInfo.lpszClassName = __EXT_NCSB_SCROLL_CONTAINER_CLASS_NAME;
- if( ! ::AfxRegisterClass( &_wndClassInfo ) )
- {
- ASSERT( FALSE );
- //AfxThrowResourceException();
- return false;
- }
- }
- e_mode_t eMode = GetMode();
- static RECT rcInitWndPos = { 0, 0, 0, 0 };
- UINT nID = UINT(__EXT_MFC_IDC_STATIC);
- CRect rc = rcInitWndPos;
- __EXT_MFC_LONG_PTR dwScrollingTargetStyle = ::__EXT_MFC_GetWindowLong( hWndScrollingTaget, GWL_STYLE );
- bool bChildMode = ( (dwScrollingTargetStyle&WS_CHILD) != 0 ) ? true : false;
- if( bChildMode && ::GetParent(m_hWndScrollingTaget) == ::GetDesktopWindow() )
- bChildMode = false;
- DWORD dwStyle = WS_CLIPCHILDREN|WS_CLIPSIBLINGS, dwExStyle = WS_EX_NOINHERITLAYOUT;
- if( bChildMode )
- {
- if( eMode == __EM_MIDDLE_CONTAINER )
- {
- ::GetWindowRect( hWndScrollingTaget, &rc );
- pWndParent->ScreenToClient( &rc );
- nID = (UINT)::__EXT_MFC_GetWindowLong( hWndScrollingTaget, GWL_ID );
- if( (dwScrollingTargetStyle&WS_VISIBLE) != 0 )
- dwStyle |= WS_VISIBLE;
- dwExStyle |= WS_EX_CONTROLPARENT;
- }
- dwStyle |= WS_CHILD;
- }
- else
- {
- ASSERT( eMode != __EM_MIDDLE_CONTAINER );
- dwStyle |= WS_POPUP;
- nID = (UINT)NULL;
- }
- if( ! CWnd::CreateEx(
- dwExStyle,
- __EXT_NCSB_SCROLL_CONTAINER_CLASS_NAME,
- __EXT_NCSB_SCROLL_CONTAINER_CLASS_NAME,
- dwStyle,
- rc,
- pWndParent,
- nID
- )
- )
- return false;
- if( eMode == __EM_HORIZONTAL_SCROLL_BAR || eMode == __EM_VERTICAL_SCROLL_BAR )
- {
- m_pWndScrollBar = OnInstantiateAndCreateScrollBar( bChildMode );
- if( m_pWndScrollBar == NULL )
- {
- DestroyWindow();
- return false;
- }
- }
- else if( eMode == __EM_MIDDLE_CONTAINER )
- {
- ::SetWindowPos(
- m_hWnd, hWndScrollingTaget, 0, 0, 0, 0,
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOREDRAW|SWP_NOSENDCHANGING
- );
- ::SetParent( hWndScrollingTaget, m_hWnd );
- CRect rcClient;
- GetClientRect( &rcClient );
- ::MoveWindow( hWndScrollingTaget, rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), TRUE );
- bool bEnable = ( (dwScrollingTargetStyle&WS_DISABLED) != 0 ) ? FALSE : TRUE;
- EnableWindow( bEnable );
- }
- return true;
- }
- void CExtNCSB_ScrollContainer::PreSubclassWindow()
- {
- ASSERT_VALID( this );
- CWnd::PreSubclassWindow();
- }
- void CExtNCSB_ScrollContainer::PostNcDestroy()
- {
- ASSERT_VALID( this );
- CExtScrollBar * pWndScrollBar = GetScrollBarInContainer();
- if( pWndScrollBar != NULL )
- {
- if( pWndScrollBar->GetSafeHwnd() != NULL )
- pWndScrollBar->DestroyWindow();
- delete pWndScrollBar;
- }
- CWnd::PostNcDestroy();
- delete this;
- }
- LRESULT CExtNCSB_ScrollContainer::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
- {
- switch( message )
- {
- case WM_NCCALCSIZE:
- return 0L;
- case WM_PAINT:
- {
- CPaintDC dcPaint( this );
- CRect rcClient;
- GetClientRect( &rcClient );
- CExtMemoryDC dc( &dcPaint, &rcClient );
- g_PaintManager->PaintDockerBkgnd( true, dc, this );
- return 0L;
- }
- case WM_SIZE:
- {
- e_mode_t eMode = GetMode();
- if( eMode == __EM_HORIZONTAL_SCROLL_BAR || eMode == __EM_VERTICAL_SCROLL_BAR )
- {
- CExtScrollBar * pWndScrollBar = GetScrollBarInContainer();
- if( pWndScrollBar->GetSafeHwnd() != NULL )
- pWndScrollBar->MoveWindow( 0, 0, LOWORD(DWORD(lParam)), HIWORD(DWORD(lParam)) );
- }
- else if( eMode == __EM_MIDDLE_CONTAINER )
- {
- HWND hWndScrollingTaget = GetSafeScrollingTargetHWND();
- if( hWndScrollingTaget != NULL )
- {
- CRect rcClient;
- GetClientRect( &rcClient );
- ::MoveWindow( hWndScrollingTaget, rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), TRUE );
- }
- }
- }
- break;
- case WM_HSCROLL:
- case WM_VSCROLL:
- {
- e_mode_t eMode = GetMode();
- if( eMode == __EM_HORIZONTAL_SCROLL_BAR || eMode == __EM_VERTICAL_SCROLL_BAR )
- {
- HWND hWndScrollingTaget = GetSafeScrollingTargetHWND();
- if( hWndScrollingTaget != NULL )
- return ::SendMessage( hWndScrollingTaget, message, wParam, NULL );
- }
- }
- return 0L;
- } // switch( message )
- LRESULT lResult = CWnd::WindowProc( message, wParam, lParam );
- switch( message )
- {
- case WM_SHOWWINDOW:
- case WM_ENABLE:
- {
- e_mode_t eMode = GetMode();
- if( eMode == __EM_MIDDLE_CONTAINER )
- {
- HWND hWndScrollingTaget = GetSafeScrollingTargetHWND();
- if( hWndScrollingTaget != NULL )
- {
- DWORD dwStyle = GetStyle();
- bool bEnable = ( (dwStyle&WS_DISABLED) != 0 ) ? FALSE : TRUE;
- ::EnableWindow( hWndScrollingTaget, bEnable );
- //int nCmdShow = ( (dwStyle&WS_VISIBLE) != 0 ) ? SW_SHOWNOACTIVATE : SW_HIDE;
- //::ShowWindow( hWndScrollingTaget, nCmdShow );
- }
- }
- }
- break;
- case WM_SETFOCUS:
- {
- e_mode_t eMode = GetMode();
- if( eMode == __EM_MIDDLE_CONTAINER )
- {
- HWND hWndScrollingTaget = GetSafeScrollingTargetHWND();
- if( hWndScrollingTaget != NULL )
- ::SetFocus( hWndScrollingTaget );
- }
- }
- break;
- } // switch( message )
- return lResult;
- }
- CExtNCSB < CListCtrl > :: CExtNCSB(
- bool bNcsbDelayedInitialization, // = false
- bool bNcsbForceMiddleContainerMode // = false
- )
- : CExtNCSB_Impl < CExtANCSB < CListCtrl > > (
- bNcsbDelayedInitialization,
- bNcsbForceMiddleContainerMode
- )
- {
- }
- CExtNCSB < CListCtrl > :: ~CExtNCSB()
- {
- }
- void CExtNCSB < CListCtrl > :: AdjustScrollMetrics()
- {
- ASSERT_VALID( this );
- if( GetSafeHwnd() == NULL )
- return;
- DWORD dwType = DWORD( GetStyle() & LVS_TYPEMASK );
- CExtNCSB_ScrollContainer * pWndH = NCSB_GetContainer( CExtNCSB_ScrollContainer::__EM_HORIZONTAL_SCROLL_BAR );
- CExtNCSB_ScrollContainer * pWndV = NCSB_GetContainer( CExtNCSB_ScrollContainer::__EM_VERTICAL_SCROLL_BAR );
- CExtScrollBar * pSBH = ( pWndH != NULL ) ? pWndH->GetScrollBarInContainer() : NULL;
- CExtScrollBar * pSBV = ( pWndV != NULL ) ? pWndV->GetScrollBarInContainer() : NULL;
- INT m_nStepSizeH = -1, m_nStepSizeV = -1;
- switch( dwType )
- {
- case LVS_ICON:
- m_nStepSizeV = 64;
- break;
- case LVS_SMALLICON:
- case LVS_LIST:
- m_nStepSizeV = 16;
- break;
- case LVS_REPORT:
- m_nStepSizeV = 1;
- break;
- } // switch( dwType )
- if( m_nStepSizeH > 0 && pSBH != NULL )
- pSBH->m_nStepSize = m_nStepSizeH;
- if( m_nStepSizeV > 0 && pSBV != NULL )
- pSBV->m_nStepSize = m_nStepSizeV;
- }
- LRESULT CExtNCSB < CListCtrl > :: WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
- {
- switch( message )
- {
- case WM_HSCROLL:
- {
- UINT nSBCode = UINT(LOWORD(DWORD(wParam))), nPos = UINT(HIWORD(DWORD(wParam)));
- //TRACE2( "WM_HSCROLL, nSBCode = %d, nPos = %drn", nSBCode, nPos );
- INT nItemExtent = 1;
- DWORD dwStyle = GetStyle();
- DWORD dwListCtrlType = dwStyle&LVS_TYPEMASK;
- switch( dwListCtrlType )
- {
- case LVS_ICON:
- case LVS_SMALLICON:
- case LVS_REPORT:
- break;
- case LVS_LIST:
- {
- CRect rcItem( 0, 0, 0, 0 );
- INT nTopIndex = GetTopIndex();
- if( nTopIndex >= 0
- && CListCtrl::GetItemRect( nTopIndex, &rcItem, LVIR_BOUNDS )
- )
- nItemExtent = rcItem.Width();
- }
- break;
- } // switch( dwListCtrlType )
- if( nSBCode == SB_THUMBTRACK || nSBCode == SB_THUMBPOSITION )
- {
- INT nPosOld = GetScrollPos( SB_HORZ );
- INT nPosShift = nPos*nItemExtent - nPosOld*nItemExtent;
- Scroll( CSize( nPosShift, 0 ) );
- return 0L;
- }
- if( nSBCode == SB_LINELEFT
- || nSBCode == SB_LINERIGHT
- || nSBCode == SB_PAGELEFT
- || nSBCode == SB_PAGERIGHT
- || nSBCode == SB_LEFT
- || nSBCode == SB_RIGHT
- || nSBCode == SB_ENDSCROLL
- )
- return 0L;
- } // case WM_HSCROLL:
- break; // case WM_VSCROLL
- case WM_VSCROLL:
- {
- UINT nSBCode = UINT(LOWORD(DWORD(wParam))), nPos = UINT(HIWORD(DWORD(wParam)));
- //TRACE2( "WM_VSCROLL, nSBCode = %d, nPos = %drn", nSBCode, nPos );
- INT nItemExtent = 1;
- DWORD dwStyle = GetStyle();
- DWORD dwListCtrlType = dwStyle&LVS_TYPEMASK;
- switch( dwListCtrlType )
- {
- case LVS_ICON:
- case LVS_SMALLICON:
- case LVS_LIST:
- break;
- case LVS_REPORT:
- {
- CRect rcItem( 0, 0, 0, 0 );
- INT nTopIndex = GetTopIndex();
- if( nTopIndex >= 0
- && CListCtrl::GetItemRect( nTopIndex, &rcItem, LVIR_BOUNDS )
- )
- nItemExtent = rcItem.Height();
- else
- {
- TEXTMETRIC _tm;
- ::memset( &_tm, 0, sizeof(TEXTMETRIC) );
- CClientDC dc( this );
- CFont * pFont = GetFont();
- int nSave = dc.SaveDC();
- dc.SelectObject( pFont );
- dc.GetTextMetrics( &_tm );
- nItemExtent = _tm.tmHeight + _tm.tmExternalLeading + 1;
- dc.RestoreDC( nSave );
- }
- }
- break;
- } // switch( dwListCtrlType )
- if( nSBCode == SB_THUMBTRACK || nSBCode == SB_THUMBPOSITION )
- {
- INT nPosOld = GetScrollPos( SB_VERT );
- INT nPosShift = nPos*nItemExtent - nPosOld*nItemExtent;
- Scroll( CSize( 0, nPosShift ) );
- return 0L;
- }
- if( nSBCode == SB_LINEUP
- || nSBCode == SB_LINEDOWN
- || nSBCode == SB_PAGEUP
- || nSBCode == SB_PAGEDOWN
- || nSBCode == SB_TOP
- || nSBCode == SB_BOTTOM
- || nSBCode == SB_ENDSCROLL
- )
- return 0L;
- }
- break; // case WM_VSCROLL
- } // switch( message )
- LRESULT lResult = CExtNCSB_Impl < CExtANCSB < CListCtrl > > :: WindowProc( message, wParam, lParam );
- switch( message )
- {
- case WM_STYLECHANGED:
- if( wParam == GWL_STYLE )
- {
- STYLESTRUCT * ptr = (STYLESTRUCT *)lParam;
- ASSERT( ptr != NULL );
- DWORD dwOldType = DWORD( ptr->styleOld & LVS_TYPEMASK );
- DWORD dwNewType = DWORD( ptr->styleNew & LVS_TYPEMASK );
- if( dwOldType != dwNewType )
- AdjustScrollMetrics();
- } // if( wParam == GWL_STYLE )
- break; // case WM_STYLECHANGED
- } // switch( message )
- return lResult;
- }
- #if (!defined __EXT_MFC_NO_SCROLLWND)
- /////////////////////////////////////////////////////////////////////////////
- // CExtScrollWnd
- IMPLEMENT_DYNCREATE( CExtScrollWnd, CWnd );
- IMPLEMENT_CExtPmBridge_MEMBERS( CExtScrollWnd );
- CExtScrollWnd::CExtScrollWnd()
- : m_nUpdateScrollBars( 0 )
- , m_bScrollPhysical( false )
- , m_bEatErasing( true )
- , m_bClientCB( false )
- , m_bBufferedPainting( true )
- , m_bScrollUpdateWindow( false )
- , m_bScrollInvalidate( true )
- , m_bScrollErase( false )
- , m_bRedrawUpdateWindow( false )
- , m_bRedrawInvalidate( true )
- , m_bRedrawErase( false )
- , m_bUse32BitScrollInfo( true )
- , m_hFont( NULL )
- {
- PmBridge_Install();
- }
- CExtScrollWnd::~CExtScrollWnd()
- {
- PmBridge_Uninstall();
- }
- BEGIN_MESSAGE_MAP(CExtScrollWnd, CWnd)
- //{{AFX_MSG_MAP(CExtScrollWnd)
- ON_WM_SIZE()
- ON_WM_HSCROLL()
- ON_WM_VSCROLL()
- ON_WM_MOUSEWHEEL()
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- ON_WM_ENABLE()
- ON_MESSAGE(WM_SETFONT, OnSetFont)
- ON_MESSAGE(WM_GETFONT, OnGetFont)
- //}}AFX_MSG_MAP
- ON_WM_SYSCOLORCHANGE()
- __EXT_MFC_SAFE_ON_WM_SETTINGCHANGE()
- ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
- ON_MESSAGE(__ExtMfc_WM_THEMECHANGED, OnThemeChanged)
- END_MESSAGE_MAP()
- void CExtScrollWnd::OnEnable( BOOL bEnable )
- {
- ASSERT_VALID( this );
- if( bEnable )
- OnSwUpdateScrollBars();
- else
- OnSwEnableScrollBarCtrl( SB_BOTH, false );
- OnSwRecalcLayout( true );
- RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ERASENOW|RDW_ALLCHILDREN|RDW_FRAME );
- }
- LRESULT CExtScrollWnd::OnSetFont( WPARAM wParam, LPARAM lParam )
- {
- ASSERT_VALID( this );
- HFONT hFont = (HFONT) wParam;
- BOOL bRedraw = (BOOL) lParam;
- m_hFont = hFont;
- OnSwRecalcLayout( true );
- if( bRedraw )
- Invalidate();
- return 0L;
- }
-
- LRESULT CExtScrollWnd::OnGetFont( WPARAM, LPARAM )
- {
- ASSERT_VALID( this );
- return (LRESULT) m_hFont;
- }
- void CExtScrollWnd::OnSysColorChange()
- {
- ASSERT_VALID( this );
- CWnd::OnSysColorChange();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnSysColorChange( this );
- // g_CmdManager.OnSysColorChange( pPM, this );
- Invalidate();
- }
- LRESULT CExtScrollWnd::OnDisplayChange( WPARAM wParam, LPARAM lParam )
- {
- LRESULT lResult = CWnd::OnDisplayChange( wParam, lParam );
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnDisplayChange( this, (INT)wParam, CPoint(lParam) );
- // g_CmdManager.OnDisplayChange( pPM, this, (INT)wParam, CPoint(lParam) );
- Invalidate();
- return lResult;
- }
- LRESULT CExtScrollWnd::OnThemeChanged( WPARAM wParam, LPARAM lParam )
- {
- wParam;
- lParam;
- LRESULT lResult = Default();
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnThemeChanged( this, wParam, lParam );
- // g_CmdManager.OnThemeChanged( pPM, this, wParam, lParam );
- OnSwRecalcLayout( true );
- Invalidate();
- return lResult;
- }
- void CExtScrollWnd::OnSettingChange(UINT uFlags, __EXT_MFC_SAFE_LPCTSTR lpszSection)
- {
- ASSERT_VALID( this );
- CWnd::OnSettingChange(uFlags, lpszSection);
- //CExtPaintManager * pPM = PmBridge_GetPM();
- // g_PaintManager.OnSettingChange( this, uFlags, lpszSection );
- // g_CmdManager.OnSettingChange( pPM, this, uFlags, lpszSection );
- OnSwRecalcLayout( true );
- Invalidate();
- }
- void CExtScrollWnd::PmBridge_OnPaintManagerChanged(
- CExtPaintManager * pGlobalPM
- )
- {
- ASSERT_VALID( this );
- CExtPmBridge::PmBridge_OnPaintManagerChanged( pGlobalPM );
- if( GetSafeHwnd() != NULL )
- OnSwRecalcLayout( true );
- }
- CSize CExtScrollWnd::OnSwGetTotalSize() const
- {
- ASSERT_VALID( this );
- return CSize( 0, 0 );
- }
- CSize CExtScrollWnd::OnSwGetPageSize( int nDirection ) const
- {
- ASSERT_VALID( this );
- nDirection;
- return CSize( 0, 0 );
- }
- CSize CExtScrollWnd::OnSwGetLineSize( int nDirection ) const
- {
- ASSERT_VALID( this );
- nDirection;
- return CSize( 0, 0 );
- }
- bool CExtScrollWnd::OnSwScrollInfoAdjust(
- int nBar,
- SCROLLINFO & si,
- bool bRedraw // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
- CScrollBar * pScrollBarWnd = GetScrollBarCtrl( nBar );
- if( pScrollBarWnd != NULL )
- {
- if( pScrollBarWnd->SetScrollInfo(
- &si,
- bRedraw ? TRUE : FALSE
- )
- )
- return true;
- return false;
- } // if( pScrollBarWnd != NULL )
- if( CWnd::SetScrollInfo(
- nBar,
- &si,
- bRedraw ? TRUE : FALSE
- )
- )
- return true;
- return false;
- }
- void CExtScrollWnd::OnSwSetScrollRange(
- int nBar,
- LONG nMinPos,
- LONG nMaxPos,
- bool bRedraw // = true
- )
- {
- ASSERT_VALID( this );
- ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
- CScrollBar * pScrollBarWnd = GetScrollBarCtrl( nBar );
- if( pScrollBarWnd != NULL )
- {
- pScrollBarWnd->SetScrollRange(
- (int)nMinPos,
- (int)nMaxPos,
- bRedraw ? TRUE : FALSE
- );
- return;
- } // if( pScrollBarWnd != NULL )
- CWnd::SetScrollRange(
- nBar,
- (int)nMinPos,
- (int)nMaxPos,
- bRedraw ? TRUE : FALSE
- );
- }
- LONG CExtScrollWnd::ScrollLimit32Get( int nBar ) const
- {
- ASSERT_VALID( this );
- ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
- CScrollBar * pScrollBarWnd = GetScrollBarCtrl( nBar );
- if( pScrollBarWnd != NULL )
- {
- if( m_bUse32BitScrollInfo )
- {
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- if( pScrollBarWnd->GetScrollInfo(
- &_scroll_info,
- SIF_RANGE|SIF_PAGE
- )
- )
- {
- LONG nRetVal = (LONG)
- (_scroll_info.nMax
- - _scroll_info.nMin
- - _scroll_info.nPage
- + 1);
- ASSERT( nRetVal >= 0 );
- return nRetVal;
- }
- //ASSERT( FALSE );
- } // if( m_bUse32BitScrollInfo )
- LONG nRetVal = (LONG)
- pScrollBarWnd->GetScrollLimit();
- return nRetVal;
- } // if( pScrollBarWnd != NULL )
- if( m_bUse32BitScrollInfo )
- {
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- if( ( const_cast < CExtScrollWnd * > ( this ) ) ->
- CWnd::GetScrollInfo(
- nBar,
- &_scroll_info,
- SIF_RANGE|SIF_PAGE
- )
- )
- {
- LONG nRetVal = (LONG)
- (_scroll_info.nMax
- - _scroll_info.nMin
- - _scroll_info.nPage
- + 1);
- ASSERT( nRetVal >= 0 );
- return nRetVal;
- }
- //ASSERT( FALSE );
- } // if( m_bUse32BitScrollInfo )
- LONG nRetVal = (LONG)
- ( ( const_cast < CExtScrollWnd * > ( this ) ) ->
- CWnd::GetScrollLimit( nBar )
- );
- return nRetVal;
- }
- void CExtScrollWnd::ScrollInfo32Get(
- int nBar,
- LONG * p_nMinPos,
- LONG * p_nMaxPos,
- LONG * p_nPageSize,
- LONG * p_nCurrPos,
- LONG * p_nTrackPos
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
- if( p_nMinPos != NULL )
- *p_nMinPos = 0L;
- if( p_nMaxPos != NULL )
- *p_nMaxPos = 0L;
- if( p_nPageSize != NULL )
- *p_nPageSize = 0L;
- if( p_nCurrPos != NULL )
- *p_nCurrPos = 0L;
- if( p_nTrackPos != NULL )
- *p_nTrackPos = 0L;
- CScrollBar * pScrollBarWnd = GetScrollBarCtrl( nBar );
- if( pScrollBarWnd != NULL )
- {
- if( m_bUse32BitScrollInfo )
- {
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- if( pScrollBarWnd->GetScrollInfo(
- &_scroll_info,
- SIF_RANGE|SIF_PAGE|SIF_POS|SIF_TRACKPOS
- )
- )
- {
- if( p_nMinPos != NULL )
- *p_nMinPos = _scroll_info.nMin;
- if( p_nMaxPos != NULL )
- *p_nMaxPos = _scroll_info.nMax;
- if( p_nPageSize != NULL )
- *p_nPageSize = _scroll_info.nPage;
- if( p_nCurrPos != NULL )
- *p_nCurrPos = _scroll_info.nPos;
- if( p_nTrackPos != NULL )
- *p_nTrackPos = _scroll_info.nTrackPos;
- return;
- }
- //ASSERT( FALSE );
- } // if( m_bUse32BitScrollInfo )
- if( p_nMinPos != NULL || p_nMaxPos != NULL )
- {
- INT nMin = 0, nMax = 0;
- pScrollBarWnd->GetScrollRange( &nMin, &nMax );
- if( p_nMinPos != NULL )
- *p_nMinPos = nMin;
- if( p_nMaxPos != NULL )
- *p_nMaxPos = nMax;
-
- } // if( p_nMinPos != NULL || p_nMaxPos != NULL )
- if( p_nCurrPos != NULL || p_nTrackPos != NULL )
- {
- INT nPos = pScrollBarWnd->GetScrollPos();
- if( p_nCurrPos != NULL )
- *p_nCurrPos = nPos;
- if( p_nTrackPos != NULL )
- *p_nTrackPos = nPos;
- } // if( p_nCurrPos != NULL || p_nTrackPos != NULL )
- return;
- } // if( pScrollBarWnd != NULL )
- if( m_bUse32BitScrollInfo )
- {
- SCROLLINFO _scroll_info;
- ::memset( &_scroll_info, 0, sizeof(SCROLLINFO) );
- _scroll_info.cbSize = sizeof(SCROLLINFO);
- if( ( const_cast < CExtScrollWnd * > ( this ) ) ->
- CWnd::GetScrollInfo(
- nBar,
- &_scroll_info,
- SIF_RANGE|SIF_PAGE|SIF_POS|SIF_TRACKPOS
- )
- )
- {
- if( p_nMinPos != NULL )
- *p_nMinPos = _scroll_info.nMin;
- if( p_nMaxPos != NULL )
- *p_nMaxPos = _scroll_info.nMax;
- if( p_nPageSize != NULL )
- *p_nPageSize = _scroll_info.nPage;
- if( p_nCurrPos != NULL )
- *p_nCurrPos = _scroll_info.nPos;
- if( p_nTrackPos != NULL )
- *p_nTrackPos = _scroll_info.nTrackPos;
- return;
- }
- //ASSERT( FALSE );
- } // if( m_bUse32BitScrollInfo )
- if( p_nMinPos != NULL || p_nMaxPos != NULL )
- {
- INT nMin = 0, nMax = 0;
- CWnd::GetScrollRange( nBar, &nMin, &nMax );
- if( p_nMinPos != NULL )
- *p_nMinPos = nMin;
- if( p_nMaxPos != NULL )
- *p_nMaxPos = nMax;
-
- } // if( p_nMinPos != NULL || p_nMaxPos != NULL )
- if( p_nCurrPos != NULL || p_nTrackPos != NULL )
- {
- INT nPos = CWnd::GetScrollPos( nBar );
- if( p_nCurrPos != NULL )
- *p_nCurrPos = nPos;
- if( p_nTrackPos != NULL )
- *p_nTrackPos = nPos;
- } // if( p_nCurrPos != NULL || p_nTrackPos != NULL )
- return;
- }
- LONG CExtScrollWnd::ScrollPos32Get(
- int nBar,
- bool bTrackPos // = false