ExtNcFrame.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:143k
- }
- }
- if( pWndFrameImpl->IsWindowEnabled()
- && ( (! NcFrameImpl_IsForceEmpty() )
- || (! NcFrameImpl_IsForceEmptyNcBorderEmpty() )
- )
- )
- {
- NcFrameImpl_DelayRgnAdjustment();
- NcFrameImpl_SetupRgn();
- }
- else
- {
- if( NcFrameImpl_IsDwmCaptionReplacement() )
- {
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- ::RedrawWindow(
- hWnd,
- NULL,
- NULL,
- RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ERASENOW|RDW_ALLCHILDREN
- );
- }
- } // if( NcFrameImpl_IsDwmCaptionReplacement() )
- }
- HWND hWndOwn = NcFrameImpl_OnQueryHWND();
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- ::SendMessage( hWndOwn, WM_NCPAINT, 0L, 0L );
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL )
- {
- ::InvalidateRect( hWnd, NULL, TRUE );
- ::UpdateWindow( hWnd );
- }
- }
- }
- break;
- case WM_NCLBUTTONDBLCLK:
- if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- {
- if( wParam == HTCAPTION || wParam == HTSYSMENU || wParam == HTTOP )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CPoint ptCursor;
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWnd, &ptCursor );
- CExtToolControlBar * pBar = DYNAMIC_DOWNCAST( CExtToolControlBar, CWnd::FromHandlePermanent( hWnd ) );
- if( pBar != NULL )
- {
- INT nToolBarButtonHT = pBar->HitTest( ptCursor );
- if( nToolBarButtonHT >= 0 )
- {
- lResult = ::SendMessage( hWnd, WM_LBUTTONDBLCLK, 0, MAKELPARAM( ptCursor.x, ptCursor.y ) );
- return true;
- }
- }
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- } // if( wParam == ...
- break;
- } // if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( wParam == HTCAPTION )
- {
- HWND hWndOwn = NcFrameImpl_OnQueryHWND();
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- bool bZoomed = ( ::IsZoomed( hWndOwn ) ) ? true : false;
- UINT nSC = bZoomed ? SC_RESTORE : SC_MAXIMIZE;
- if( NcFrameImpl_OnQuerySystemCommandEnabled( SC_RESTORE )
- || NcFrameImpl_OnQuerySystemCommandEnabled( SC_MAXIMIZE )
- )
- ::SendMessage( hWndOwn, WM_SYSCOMMAND, WPARAM(nSC), lParam );
- lResult = 0L;
- return true;
- } // if( wParam == HTCAPTION )
- else if( wParam == HTSYSMENU )
- {
- if( NcFrameImpl_OnQuerySystemCommandEnabled( SC_CLOSE ) )
- {
- HWND hWndOwn = pWndFrameImpl->GetSafeHwnd();
- ::SendMessage( hWndOwn, WM_SYSCOMMAND, SC_CLOSE, lParam );
- if( ::IsWindow( hWndOwn ) )
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- lResult = 0L;
- return true;
- } // if( NcFrameImpl_OnQuerySystemCommandEnabled( SC_CLOSE ) )
- } // else if( wParam == HTSYSMENU )
- break;
- case WM_NCHITTEST:
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmCaptionReplacement() )
- {
- if( g_PaintManager.m_DWM.DwmDefWindowProc(
- pWndFrameImpl->m_hWnd,
- message,
- wParam,
- lParam,
- &lResult
- )
- )
- return true;
- INT nV = ::GetSystemMetrics( SM_CYFRAME );
- INT nCV = nV + ::GetSystemMetrics( SM_CYCAPTION );
- if( pWndFrameImpl->IsZoomed() )
- nCV += nV;
- CPoint pointScreen;
- if( ::GetCursorPos( &pointScreen ) )
- {
- CRect rc;
- pWndFrameImpl->GetWindowRect( &rc );
- rc.bottom = rc.top + nV;
- if( rc.PtInRect( pointScreen ) )
- {
- lResult = HTTOP;
- return true;
- }
- rc.bottom = rc.top + nCV;
- rc.DeflateRect( ::GetSystemMetrics(SM_CXFRAME), 0 );
- if( rc.PtInRect( pointScreen ) )
- {
- lResult = HTCAPTION;
- return true;
- }
- }
- }
- if( NcFrameImpl_IsDwmBased() )
- break;
- if( ! NcFrameImpl_IsForceEmpty() )
- {
- if( m_bNcFrameImpl_HelperInsideNcHitTest )
- {
- lResult = HTNOWHERE;
- return true;
- }
- m_bNcFrameImpl_HelperInsideNcHitTest = true;
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointScreen, pointWnd( -32767, -32767 );
- if( ::GetCursorPos( &pointScreen ) )
- {
- pointWnd = pointScreen;
- pointWnd -= rcWnd.TopLeft();
- }
- if( m_pNcFrameImplBridge != NULL )
- {
- HRGN hRgn = m_pNcFrameImplBridge->NcFrameImplBridge_GetNcResizingHRGN();
- if( hRgn != NULL
- && ::PtInRegion( hRgn, pointWnd.x, pointWnd.y )
- )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTTOPLEFT;
- lResult = HTTOPLEFT;
- //NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- ::SetCursor( ::LoadCursor( NULL, IDC_SIZENWSE ) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- }
- CRect rcTmp = NcFrameImpl_GetNcScRect( SC_CLOSE );
- if( rcTmp.PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTCLOSE;
- lResult = HTCAPTION;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(HTCLOSE) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- rcTmp.OffsetRect( rcWnd.TopLeft() );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+0 );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+1 );
- ::InvalidateRect( hWnd, &rcTmp, TRUE );
- if( m_rcNcFrameImpl_LastExternalNcHT != rcTmp )
- {
- ::InvalidateRect( hWnd, &m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- m_rcNcFrameImpl_LastExternalNcHT = rcTmp;
- }
- //::UpdateWindow( hWnd );
- }
- }
- return true;
- }
- rcTmp = NcFrameImpl_GetNcScRect( SC_MINIMIZE );
- if( rcTmp.PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTMINBUTTON;
- lResult = HTCAPTION;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(HTMINBUTTON) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- rcTmp.OffsetRect( rcWnd.TopLeft() );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+0 );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+1 );
- ::InvalidateRect( hWnd, &rcTmp, TRUE );
- if( m_rcNcFrameImpl_LastExternalNcHT != rcTmp )
- {
- ::InvalidateRect( hWnd, &m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- m_rcNcFrameImpl_LastExternalNcHT = rcTmp;
- }
- //::UpdateWindow( hWnd );
- }
- }
- return true;
- }
- rcTmp = NcFrameImpl_GetNcScRect( SC_MAXIMIZE );
- if( rcTmp.PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTMAXBUTTON;
- lResult = HTCAPTION;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(HTMAXBUTTON) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- rcTmp.OffsetRect( rcWnd.TopLeft() );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+0 );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+1 );
- ::InvalidateRect( hWnd, &rcTmp, TRUE );
- if( m_rcNcFrameImpl_LastExternalNcHT != rcTmp )
- {
- ::InvalidateRect( hWnd, &m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- m_rcNcFrameImpl_LastExternalNcHT = rcTmp;
- }
- }
- }
- return true;
- }
- rcTmp = NcFrameImpl_GetNcScRect( SC_CONTEXTHELP );
- if( rcTmp.PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTHELP;
- lResult = HTCAPTION;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(HTHELP) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- rcTmp.OffsetRect( rcWnd.TopLeft() );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+0 );
- ::ScreenToClient( hWnd, ((LPPOINT)(&rcTmp))+1 );
- ::InvalidateRect( hWnd, &rcTmp, TRUE );
- if( m_rcNcFrameImpl_LastExternalNcHT != rcTmp )
- {
- ::InvalidateRect( hWnd, &m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- m_rcNcFrameImpl_LastExternalNcHT = rcTmp;
- }
- }
- }
- return true;
- }
- // MINMAXINFO _mmi, * pMinMaxInfo = NULL;
- // ::memset( &_mmi, 0, sizeof(MINMAXINFO) );
- // CExtPaintManager::monitor_parms_t _mp;
- // CExtPaintManager::stat_GetMonitorParms( _mp, pWndFrameImpl );
- // _mmi.ptMaxPosition.x = _mp.m_rcWorkArea.left;
- // _mmi.ptMaxPosition.y = _mp.m_rcWorkArea.top;
- // _mmi.ptMaxTrackSize.x = _mp.m_rcWorkArea.Width(); // ::GetSystemMetrics( SM_CXMAXTRACK );
- // _mmi.ptMaxTrackSize.y = _mp.m_rcWorkArea.Height(); // ::GetSystemMetrics( SM_CYMAXTRACK );
- // _mmi.ptMinTrackSize.x = ::GetSystemMetrics( SM_CXMINTRACK );
- // _mmi.ptMinTrackSize.y = ::GetSystemMetrics( SM_CYMINTRACK );
- // _mmi.ptMaxSize.x = _mmi.ptMaxTrackSize.x;
- // _mmi.ptMaxSize.y = _mmi.ptMaxTrackSize.y;
- // if( pWndFrameImpl->SendMessage( WM_GETMINMAXINFO, 0, LPARAM(&_mmi) ) == 0 )
- // pMinMaxInfo = &_mmi;
- MINMAXINFO * pMinMaxInfo = &m_NcFrameImpl_MinMaxInfo_Cache;
- pWndFrameImpl->ModifyStyle( WS_CAPTION|WS_BORDER, 0, 0 );
- Sleep( 1 ); // this line of code magically fixes 50-100% CPU eating problem when moving mouse over skinable NC areas
- if( NcFrameImpl_GetNcHtRect(HTTOPLEFT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTTOPLEFT;
- lResult = HTTOPLEFT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTTOPRIGHT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTTOPRIGHT;
- lResult = HTTOPRIGHT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTBOTTOMLEFT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTBOTTOMLEFT;
- lResult = HTBOTTOMLEFT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTBOTTOMRIGHT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTBOTTOMRIGHT;
- lResult = HTBOTTOMRIGHT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTTOP,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTTOP;
- lResult = HTTOP;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTBOTTOM,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTBOTTOM;
- lResult = HTBOTTOM;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTLEFT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTLEFT;
- lResult = HTLEFT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTRIGHT,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTRIGHT;
- lResult = HTRIGHT;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTSYSMENU,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTSYSMENU;
- lResult = HTSYSMENU;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- // if( pWndFrameImpl->IsIconic() && (! CExtPopupMenuWnd::IsKeyPressed( VK_LBUTTON) ) )
- // lResult = HTNOWHERE;
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- if( NcFrameImpl_GetNcHtRect(HTCAPTION,false,false,false,pMinMaxInfo,&rcWnd).PtInRect(pointWnd) )
- {
- m_nNcFrameImpl_LastExternalNcHT = HTCAPTION;
- lResult = HTCAPTION;
- NcFrameImpl_CheckCursor( pointScreen, LPARAM(lResult) );
- // if( pWndFrameImpl->IsIconic() && (! CExtPopupMenuWnd::IsKeyPressed( VK_LBUTTON) ) )
- // lResult = HTNOWHERE;
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- return true;
- }
- m_bNcFrameImpl_HelperInsideNcHitTest = false;
- } // if( ! NcFrameImpl_IsForceEmpty() )
- lResult = HTCLIENT;
- return true;
- //break;
- case WM_NCCALCSIZE:
- if( pWndFrameImpl->IsIconic() )
- break;
- { // BLOCK: adjust MDI client area styles
- HWND hWndMdiClient = CExtControlBar::stat_FindMdiClientHWND( pWndFrameImpl->m_hWnd );
- if( hWndMdiClient != NULL )
- {
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_STYLE );
- if( (dwStyle&WS_BORDER) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_STYLE, dwStyle&(~(WS_BORDER)) );
- __EXT_MFC_LONG_PTR dwStyleEx = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_EXSTYLE );
- if( (dwStyleEx&(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_EXSTYLE, (dwStyleEx&(~(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)))|WS_EX_CLIENTEDGE );
- }
- } // BLOCK: adjust MDI client area styles
- if( pWndFrameImpl->IsKindOf( RUNTIME_CLASS( CMDIChildWnd ) )
- && m_bNcFrameImpl_IsActive
- && (pWndFrameImpl->GetStyle()&WS_MAXIMIZE) != 0
- )
- break;
- else
- {
- bool bNcCaptionMerging = false;
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL
- && m_pNcFrameImplBridge->NcFrameImplBridge_OnQueryCaptionMergeMode()
- )
- {
- bNcCaptionMerging = true;
- if( ! m_bNcFrameImpl_CreatePassed )
- return false;
- if( NcFrameImpl_IsNcLocked() )
- return false;
- CFrameWnd * pFrame = DYNAMIC_DOWNCAST( CFrameWnd, pWndFrameImpl );
- if( pFrame != NULL )
- {
- bool bIsLoading = false;
- if( CExtControlBar::ProfileBarStateIsSerializing( pFrame, &bIsLoading ) )
- {
- if( bIsLoading )
- return false;
- }
- }
- }
- }
- CExtUxTheme::__EXT_UX_MARGINS _margins = { 0, 0, 0, 0 };
- bool bDwmMode = NcFrameImpl_IsDwmBased();
- if( bDwmMode && ( ! bNcCaptionMerging ) )
- {
- m_bNcFrameImpl_DwmSurfaceInitializationComplete = false;
- g_PaintManager.m_DWM.DwmExtendFrameIntoClientArea( pWndFrameImpl->m_hWnd, &_margins );
- return false;
- }
- if( ! NcFrameImpl_IsNcLocked() )
- {
- NCCALCSIZE_PARAMS * pNCCSP =
- reinterpret_cast < NCCALCSIZE_PARAMS * > ( lParam );
- ASSERT( pNCCSP != NULL );
- if( bNcCaptionMerging && bDwmMode )
- {
- INT nV = ::GetSystemMetrics( SM_CYFRAME );
- INT nCV = nV + ::GetSystemMetrics( SM_CYCAPTION );
- INT nLeftRight = ::GetSystemMetrics( SM_CXFRAME ), nTopBottom = nV;
- if( pWndFrameImpl->IsZoomed() )
- nCV += nV;
- _margins.cyTopHeight = nCV;
- pNCCSP->rgrc[0].left += nLeftRight;
- pNCCSP->rgrc[0].right -= nLeftRight;
- pNCCSP->rgrc[0].bottom -= nTopBottom;
- } // if( bNcCaptionMerging && bDwmMode )
- else if( NcFrameImpl_IsForceEmpty() )
- {
- if( ! NcFrameImpl_IsForceEmptyNcBorderEmpty() )
- {
- CRect rc = NcFrameImpl_GetForceEmptyNcBorder();
- if( ! bNcCaptionMerging )
- pNCCSP->rgrc[0].top += rc.top;
- pNCCSP->rgrc[0].left += rc.left;
- pNCCSP->rgrc[0].right -= rc.right;
- pNCCSP->rgrc[0].bottom -= rc.bottom;
- } // if( ! NcFrameImpl_IsForceEmptyNcBorderEmpty() )
- } // else if( NcFrameImpl_IsForceEmpty() )
- else
- {
- CRect rcNcBorders, rcThemePadding;
- NcFrameImpl_GetPM()->NcFrame_GetMetrics(
- rcNcBorders,
- rcThemePadding,
- pWndFrameImpl
- );
- if( ! bNcCaptionMerging )
- pNCCSP->rgrc[0].top += rcThemePadding.top;
- pNCCSP->rgrc[0].left += rcThemePadding.left;
- pNCCSP->rgrc[0].right -= rcThemePadding.right;
- pNCCSP->rgrc[0].bottom -= rcThemePadding.bottom;
- // bool bMaximized = ( ( pWndFrameImpl->GetStyle() & WS_MAXIMIZE ) != 0 ) ? true : false;
- // if( bMaximized )
- // {
- // pNCCSP->rgrc[0].left -= rcNcBorders.left;
- // pNCCSP->rgrc[0].right += rcNcBorders.right;
- // pNCCSP->rgrc[0].top -= rcNcBorders.top;
- // pNCCSP->rgrc[0].bottom += rcNcBorders.bottom;
- // }
- if( m_pNcFrameImplBridge != NULL
- && m_pNcFrameImplBridge->NcFrameImplBridge_OnQueryCaptionMergeMode()
- )
- pNCCSP->rgrc[0].top -=
- NcFrameImpl_GetPM() ->
- NcFrame_GetCaptionHeight(
- NcFrameImpl_IsActive(),
- NcFrameImpl_GetFrameWindow()
- );
- }
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- if( bDwmMode )
- GetWindowPlacement( &_wp );
- if( m_pNcFrameImplBridge != NULL && NcFrameImpl_IsDwmCaptionReplacement() )
- {
- m_pNcFrameImplBridge->NcFrameImpl_PreSetWindowPlacement( _wp );
- m_pNcFrameImplBridge->NcFrameImpl_AdjustDwmArea( _margins );
- }
- m_bNcFrameImpl_DwmSurfaceInitializationComplete = true;
- g_PaintManager.m_DWM.DwmExtendFrameIntoClientArea( pWndFrameImpl->m_hWnd, &_margins );
- if( m_pNcFrameImplBridge != NULL && NcFrameImpl_IsDwmCaptionReplacement() )
- m_pNcFrameImplBridge->NcFrameImpl_PostSetWindowPlacement( _wp );
- } // if( ! NcFrameImpl_IsNcLocked() )
- lResult = 0;
- return true;
- }
- case WM_NCPAINT:
- if( ! NcFrameImpl_IsDwmBased() )
- {
- if( (! NcFrameImpl_IsForceEmpty() )
- // || m_bNcFrameImpl_RestoreEnabledState
- )
- {
- CMDIChildWnd * pWndMdiChild = DYNAMIC_DOWNCAST( CMDIChildWnd, pWndFrameImpl );
- if( pWndMdiChild != NULL )
- {
- HWND hWndMDIClient = ::GetParent( pWndMdiChild->m_hWnd );
- HWND hWndActiveChildFrame = (HWND) ::SendMessage( hWndMDIClient, WM_MDIGETACTIVE, 0, NULL );
- if( hWndActiveChildFrame != NULL )
- m_bNcFrameImpl_IsActive = ( hWndActiveChildFrame == pWndMdiChild->m_hWnd ) ? true : false;
- }
- CWindowDC dcPaint( pWndFrameImpl );
- NcFrameImpl_OnNcPaint( dcPaint );
- lResult = 0;
- return true;
- }
- } //if( ! NcFrameImpl_IsDwmBased() )
- break;
- case WM_NCLBUTTONUP:
- if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- {
- if( wParam == HTCAPTION || wParam == HTSYSMENU || wParam == HTTOP )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CPoint ptCursor;
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWnd, &ptCursor );
- CExtToolControlBar * pBar = DYNAMIC_DOWNCAST( CExtToolControlBar, CWnd::FromHandlePermanent( hWnd ) );
- if( pBar != NULL )
- {
- INT nToolBarButtonHT = pBar->HitTest( ptCursor );
- if( nToolBarButtonHT >= 0 )
- {
- lResult = ::SendMessage( hWnd, WM_LBUTTONUP, 0, MAKELPARAM( ptCursor.x, ptCursor.y ) );
- return true;
- }
- }
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- } // if( wParam == ...
- break;
- } // if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- if( ! NcFrameImpl_IsSupported() )
- break;
- return true;
- // break;
- case WM_NCLBUTTONDOWN:
- {
- if( ! NcFrameImpl_IsSupported() )
- break;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- {
- if( wParam == HTCAPTION || wParam == HTSYSMENU || wParam == HTTOP )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CPoint ptCursor;
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWnd, &ptCursor );
- CExtToolControlBar * pBar = DYNAMIC_DOWNCAST( CExtToolControlBar, CWnd::FromHandlePermanent( hWnd ) );
- if( pBar != NULL )
- {
- CExtPaintManager * pPM = NcFrameImpl_GetPM();
- ASSERT_VALID( pPM );
- if( ( (! pPM->Ribbon_FileButtonIsItegrationSupported() )
- || pPM->Ribbon_IsSystemMenuIconPresent()
- )
- && pBar->IsKindOf( RUNTIME_CLASS(CExtMenuControlBar) )
- )
- {
- CRect rc;
- pBar->GetClientRect( &rc );
- rc.right = rc.left + ::GetSystemMetrics(SM_CXICON) / 2;
- rc.bottom = rc.top + ::GetSystemMetrics(SM_CYICON) / 2;
- rc.OffsetRect( 0, ::GetSystemMetrics(SM_CXFRAME) );
- if( rc.PtInRect( ptCursor ) )
- {
- ((CExtMenuControlBar*)pBar)->TrackMainFrameSystemMenu();
- return true;
- }
- }
- INT nToolBarButtonHT = pBar->HitTest( ptCursor );
- if( nToolBarButtonHT >= 0 )
- {
- lResult = ::SendMessage( hWnd, WM_LBUTTONDOWN, 0, MAKELPARAM( ptCursor.x, ptCursor.y ) );
- return true;
- }
- }
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- } // if( wParam == ...
- break;
- } // if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- #endif // #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( ( ! ( m_bNcFrameImpl_Resizing || m_bNcFrameImpl_Moving ) )
- && ( ! NcFrameImpl_IsDwmBased() )
- )
- m_bNcFrameImpl_Resizing = m_bNcFrameImpl_Moving = true;
- if( m_bNcFrameImpl_Resizing || m_bNcFrameImpl_Moving )
- {
- if( NcFrameImpl_IsDwmBased() )
- m_bNcFrameImpl_Resizing = m_bNcFrameImpl_Moving = false;
- if( ::GetActiveWindow() != pWndFrameImpl->m_hWnd )
- pWndFrameImpl->SetActiveWindow();
- }
- m_nNcFrameImpl_ScTrackedButtonPressed = 0;
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointWnd;
- ::GetCursorPos( &pointWnd );
- pointWnd -= rcWnd.TopLeft();
- if( m_rcNcFrameImpl_ScClose.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_CLOSE;
- else if( m_rcNcFrameImpl_ScMaximize.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_MAXIMIZE;
- else if( m_rcNcFrameImpl_ScMinimize.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_MINIMIZE;
- else if( m_rcNcFrameImpl_ScHelp.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_CONTEXTHELP;
- if( m_nNcFrameImpl_ScTrackedButtonPressed != 0 )
- {
- HWND hWnd = NULL;
- if( m_pNcFrameImplBridge != NULL
- && ( hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() ) != NULL
- && (! m_rcNcFrameImpl_LastExternalNcHT.IsRectEmpty() )
- )
- ::InvalidateRect( hWnd, m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- if( m_nNcFrameImpl_ScTrackedButtonPressed != 0
- && CWnd::GetCapture() != pWndFrameImpl
- )
- pWndFrameImpl->SetCapture();
- } // if( m_nNcFrameImpl_ScTrackedButtonPressed != 0 )
- if( /*
- m_bNcFrameImpl_Moving
- &&*/
- wParam == HTSYSMENU
- )
- { // system menu tracking code
- lResult = 0;
- return false;
- } // system menu tracking code
- else if(
- m_bNcFrameImpl_Moving
- && wParam == HTCAPTION
- )
- { // track moving loop
- DWORD dwStyle = pWndFrameImpl->GetStyle();
- static const DWORD dwCheckMask = WS_MAXIMIZE|WS_VISIBLE|WS_DISABLED;
- DWORD dwCheckResult = dwStyle&dwCheckMask;
- if( dwCheckResult != WS_VISIBLE )
- {
- lResult = 0;
- return true;
- }
- m_bNcFrameImpl_MovingLoopTracking = true;
- HWND hWnd = pWndFrameImpl->GetSafeHwnd();
- ::SendMessage( hWnd, WM_ENTERSIZEMOVE, 0L, 0L );
- ::SetCapture( hWnd );
- CPoint ptStart( short(LOWORD(lParam)), short(HIWORD(lParam)) );
- CRect rcWndStart;
- ::GetWindowRect( hWnd, rcWndStart );
- HANDLE hCurrentThread = ::GetCurrentThread();
- int nOldCurrentThreadPriority = ::GetThreadPriority( hCurrentThread );
- ::SetThreadPriority( hCurrentThread, THREAD_PRIORITY_ABOVE_NORMAL );
- HANDLE hProcess = ::GetCurrentProcess();
- DWORD dwOldProcessPriorityClass = ::GetPriorityClass( hProcess );
- ::SetPriorityClass( hProcess, HIGH_PRIORITY_CLASS );
- bool bStop = false, bStartDetected = false;
- for( ; ! bStop ; )
- {
- ::WaitMessage();
- MSG msg;
- // Process all the messages in the message queue
- while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
- {
- switch( msg.message )
- {
- case WM_ACTIVATEAPP:
- case WM_CANCELMODE:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_NCMBUTTONDBLCLK:
- case WM_CONTEXTMENU:
- bStop = true;
- break;
- case WM_CAPTURECHANGED:
- if( hWnd != ((HWND)lParam) )
- bStop = true;
- break;
- case WM_SIZE:
- case WM_WINDOWPOSCHANGING:
- case WM_WINDOWPOSCHANGED:
- case WM_ERASEBKGND:
- case WM_NCHITTEST:
- case WM_NCMOUSEMOVE:
- if( ::IsWindow( hWnd ) )
- {
- ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
- continue;
- }
- bStop = true;
- break;
- case WM_MOUSEMOVE:
- ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
- if( msg.hwnd == hWnd )
- {
- // while( ::PeekMessage( &msg, hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) )
- // {
- // if( ::PeekMessage( &msg, hWnd, WM_NCLBUTTONUP, WM_NCLBUTTONUP, PM_NOREMOVE ) )
- // break;
- // }
- CPoint pt;
- if( ! ::GetCursorPos( &pt ) )
- {
- bStop = true;
- break;
- }
- if( ( ::__EXT_MFC_GetWindowLong(hWnd,GWL_STYLE) & WS_CHILD ) != 0 )
- {
- HWND hWndParent = ::GetParent( hWnd );
- ASSERT( hWndParent != NULL );
- CRect rcWndParent;
- ::GetWindowRect( hWndParent, &rcWndParent );
- pt.x = max( pt.x, rcWndParent.left );
- pt.x = min( pt.x, rcWndParent.right );
- pt.y = max( pt.y, rcWndParent.top );
- pt.y = min( pt.y, rcWndParent.bottom );
- }
- CPoint ptOffset(
- pt.x - ptStart.x,
- pt.y - ptStart.y
- );
- if( (! bStartDetected )
- && abs( ptOffset.x ) < 5
- && abs( ptOffset.y ) < 5
- )
- continue;
- bStartDetected = true;
- CRect rcWnd = rcWndStart;
- rcWnd.OffsetRect( ptOffset );
- CRect rcWndCurrent;
- ::GetWindowRect( hWnd, &rcWndCurrent );
- if( rcWndCurrent != rcWnd )
- {
- if( ( ::__EXT_MFC_GetWindowLong(hWnd,GWL_STYLE) & WS_CHILD ) != 0 )
- {
- HWND hWndParent = ::GetParent( hWnd );
- ASSERT( hWndParent != NULL );
- ::ScreenToClient( hWndParent, ((LPPOINT)&rcWnd) );
- ::ScreenToClient( hWndParent, ((LPPOINT)&rcWnd)+1 );
- }
- CRect rcWndAdjusted = rcWnd;
- if( ::SendMessage( hWnd, WM_MOVING, 0L, LPARAM(&rcWndAdjusted) ) != 0L )
- rcWnd = rcWndAdjusted;
- ::MoveWindow( hWnd, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), TRUE );
- SendMessage( hWnd, WM_NCPAINT, 0, 0 );
- CExtPaintManager::stat_PassPaintMessages();
- ::Sleep(1);
- } // if( rcWndCurrent != rcWnd )
- } // if( msg.hwnd == hWnd )
- if( ::IsWindow( hWnd ) )
- continue;
- bStop = true;
- break;
- default:
- if( WM_KEYFIRST <= msg.message
- && msg.message <= WM_KEYLAST
- )
- bStop = true;
- break;
- } // switch( msg.message )
- if( ! ::IsWindow( hWnd ) )
- bStop = true;
- if( bStop )
- break;
- CWinThread * pThread = AfxGetThread();
- if( pThread == NULL )
- ::DispatchMessage( &msg );
- else
- if( ! pThread->PumpMessage() )
- {
- PostQuitMessage(0);
- break; // Signal WM_QUIT received
- } // if( !AfxGetThread()->PumpMessage() )
- } // while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
- if( bStop )
- break;
- for( LONG nIdleCounter = 0L;
- true; // ::AfxGetThread()->OnIdle(nIdleCounter);
- nIdleCounter ++
- )
- {
- CWinThread * pThread = AfxGetThread();
- if( pThread == NULL )
- break;
- if( ! pThread->OnIdle( nIdleCounter ) )
- break;
- }
- } // for( ; ! bStop ; )
- ::SetThreadPriority( hCurrentThread, nOldCurrentThreadPriority );
- ::CloseHandle( hCurrentThread );
- ::SetPriorityClass( hProcess, dwOldProcessPriorityClass );
- ::CloseHandle( hProcess );
- if( ::IsWindow( hWnd ) )
- {
- m_bNcFrameImpl_MovingLoopTracking = false;
- if( ::GetCapture() == hWnd )
- ::ReleaseCapture();
- }
- ::SendMessage( hWnd, WM_EXITSIZEMOVE, 0L, 0L );
- lResult = 0;
- return true;
- } // track moving loop
- else if(
- m_bNcFrameImpl_Resizing
- && ( wParam == HTLEFT
- || wParam == HTRIGHT
- || wParam == HTTOP
- || wParam == HTBOTTOM
- || wParam == HTTOPLEFT
- || wParam == HTBOTTOMLEFT
- || wParam == HTTOPRIGHT
- || wParam == HTBOTTOMRIGHT
- )
- )
- { // track resizing loop
- DWORD dwStyle = pWndFrameImpl->GetStyle();
- static const DWORD dwCheckMask = WS_MAXIMIZE|WS_MINIMIZE|WS_VISIBLE|WS_DISABLED;
- DWORD dwCheckResult = dwStyle&dwCheckMask;
- if( dwCheckResult != WS_VISIBLE )
- {
- lResult = 0;
- return true;
- }
- WPARAM wParamSizingCode = 0L;
- switch( wParam )
- {
- case HTTOP: wParamSizingCode = WMSZ_TOP; break;
- case HTBOTTOM: wParamSizingCode = WMSZ_BOTTOM; break;
- case HTLEFT: wParamSizingCode = WMSZ_LEFT; break;
- case HTRIGHT: wParamSizingCode = WMSZ_RIGHT; break;
- case HTTOPLEFT: wParamSizingCode = WMSZ_TOPLEFT; break;
- case HTTOPRIGHT: wParamSizingCode = WMSZ_TOPRIGHT; break;
- case HTBOTTOMLEFT: wParamSizingCode = WMSZ_BOTTOMLEFT; break;
- case HTBOTTOMRIGHT: wParamSizingCode = WMSZ_BOTTOMRIGHT; break;
- } // switch( wParam )
- ASSERT( wParamSizingCode != 0L );
- HWND hWnd = pWndFrameImpl->GetSafeHwnd();
- ::SendMessage( hWnd, WM_ENTERSIZEMOVE, 0L, 0L );
- ::SetCapture( hWnd );
- CPoint ptStart( short(LOWORD(lParam)), short(HIWORD(lParam)) );
- CRect rcWndStart;
- ::GetWindowRect( hWnd, rcWndStart );
- HANDLE hCurrentThread = ::GetCurrentThread();
- int nOldCurrentThreadPriority = ::GetThreadPriority( hCurrentThread );
- ::SetThreadPriority( hCurrentThread, THREAD_PRIORITY_ABOVE_NORMAL );
- HANDLE hProcess = ::GetCurrentProcess();
- DWORD dwOldProcessPriorityClass = ::GetPriorityClass( hProcess );
- ::SetPriorityClass( hProcess, HIGH_PRIORITY_CLASS );
- m_bNcFrameImpl_ResizingLoopTracking = true;
- MINMAXINFO _mmi;
- // ::memset( &_mmi, 0, sizeof(MINMAXINFO) );
- // CExtPaintManager::monitor_parms_t _mp;
- // CExtPaintManager::stat_GetMonitorParms( _mp, (CWnd*)pWndFrameImpl );
- // _mmi.ptMaxPosition.x = _mp.m_rcWorkArea.left;
- // _mmi.ptMaxPosition.y = _mp.m_rcWorkArea.top;
- // _mmi.ptMaxTrackSize.x = _mp.m_rcWorkArea.Width(); // ::GetSystemMetrics( SM_CXMAXTRACK );
- // _mmi.ptMaxTrackSize.y = _mp.m_rcWorkArea.Height(); // ::GetSystemMetrics( SM_CYMAXTRACK );
- // _mmi.ptMinTrackSize.x = ::GetSystemMetrics( SM_CXMINTRACK );
- // _mmi.ptMinTrackSize.y = ::GetSystemMetrics( SM_CYMINTRACK );
- // _mmi.ptMaxSize.x = _mmi.ptMaxTrackSize.x;
- // _mmi.ptMaxSize.y = _mmi.ptMaxTrackSize.y;
- // pWndFrameImpl->SendMessage( WM_GETMINMAXINFO, 0, LPARAM(&_mmi) );
- ::memcpy( &_mmi, &m_NcFrameImpl_MinMaxInfo_Cache, sizeof(MINMAXINFO) );
- NcFrameImpl_GetMinMaxInfo( &_mmi );
- bool bStop = false;
- for( ; ! bStop ; )
- {
- ::WaitMessage();
- MSG msg;
- // Process all the messages in the message queue
- while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
- {
- switch( msg.message )
- {
- case WM_ACTIVATEAPP:
- case WM_CANCELMODE:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_NCMBUTTONDBLCLK:
- case WM_CONTEXTMENU:
- bStop = true;
- break;
- case WM_CAPTURECHANGED:
- if( hWnd != ((HWND)lParam) )
- bStop = true;
- break;
- case WM_SIZE:
- case WM_WINDOWPOSCHANGING:
- case WM_WINDOWPOSCHANGED:
- case WM_ERASEBKGND:
- case WM_NCHITTEST:
- case WM_NCMOUSEMOVE:
- if( ::IsWindow( hWnd ) )
- {
- ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
- continue;
- }
- bStop = true;
- break;
- case WM_MOUSEMOVE:
- ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
- if( msg.hwnd == hWnd )
- {
- // while( ::PeekMessage( &msg, hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) )
- // {
- // if( ::PeekMessage( &msg, hWnd, WM_NCLBUTTONUP, WM_NCLBUTTONUP, PM_NOREMOVE ) )
- // break;
- // }
- CPoint pt;
- if( ! ::GetCursorPos( &pt ) )
- {
- bStop = true;
- break;
- }
- CRect rcWnd = rcWndStart;
- if( wParam == HTLEFT
- || wParam == HTTOPLEFT
- || wParam == HTBOTTOMLEFT
- )
- {
- rcWnd.left = rcWndStart.left + pt.x - ptStart.x;
- if( rcWnd.Width() < _mmi.ptMinTrackSize.x )
- rcWnd.left = rcWnd.right - _mmi.ptMinTrackSize.x;
- if( rcWnd.Width() > _mmi.ptMaxTrackSize.x )
- rcWnd.left = rcWnd.right - _mmi.ptMaxTrackSize.x;
- //if( rcWnd.left > rcWndStart.left )
- // rcWnd.left = rcWndStart.left;
- }
- if( wParam == HTRIGHT
- || wParam == HTTOPRIGHT
- || wParam == HTBOTTOMRIGHT
- )
- {
- rcWnd.right = rcWndStart.right + pt.x - ptStart.x;
- if( rcWnd.Width() < _mmi.ptMinTrackSize.x )
- rcWnd.right = rcWnd.left + _mmi.ptMinTrackSize.x;
- if( rcWnd.Width() > _mmi.ptMaxTrackSize.x )
- rcWnd.right = rcWnd.left + _mmi.ptMaxTrackSize.x;
- //if( rcWnd.right < rcWndStart.right )
- // rcWnd.right = rcWndStart.right;
- }
- if( wParam == HTTOP
- || wParam == HTTOPLEFT
- || wParam == HTTOPRIGHT
- )
- {
- rcWnd.top = rcWndStart.top + pt.y - ptStart.y;
- if( rcWnd.Height() < _mmi.ptMinTrackSize.y )
- rcWnd.top = rcWnd.bottom - _mmi.ptMinTrackSize.y;
- if( rcWnd.Height() > _mmi.ptMaxTrackSize.y )
- rcWnd.top = rcWnd.bottom - _mmi.ptMaxTrackSize.y;
- //if( rcWnd.top > rcWndStart.top )
- // rcWnd.top = rcWndStart.top;
- }
- if( wParam == HTBOTTOM
- || wParam == HTBOTTOMLEFT
- || wParam == HTBOTTOMRIGHT
- )
- {
- rcWnd.bottom = rcWndStart.bottom + pt.y - ptStart.y;
- if( rcWnd.Height() < _mmi.ptMinTrackSize.y )
- rcWnd.bottom = rcWnd.top + _mmi.ptMinTrackSize.y;
- if( rcWnd.Height() > _mmi.ptMaxTrackSize.y )
- rcWnd.bottom = rcWnd.top + _mmi.ptMaxTrackSize.y;
- //if( rcWnd.bottom < rcWndStart.bottom )
- // rcWnd.bottom = rcWndStart.bottom;
- }
- CRect rcWndCurrent;
- ::GetWindowRect( hWnd, &rcWndCurrent );
- if( rcWndCurrent != rcWnd )
- {
- UINT nIDFirst = 0, nIDLast = 0xFFFF, nIDLeftOver = AFX_IDW_PANE_FIRST;
- AFX_SIZEPARENTPARAMS layout = { NULL, { 0, 0, 0, 0 }, { 0, 0 }, FALSE };
- HWND hWndLeftOver = NULL;
- layout.bStretch = TRUE;
- CRect rcClientCurrent;
- ::GetClientRect( hWnd, &rcClientCurrent );
- layout.rect.right = rcClientCurrent.right + rcWnd.Width() - rcWndCurrent.Width();
- layout.rect.bottom = rcClientCurrent.bottom + rcWnd.Height() - rcWndCurrent.Height();
- layout.hDWP = ::BeginDeferWindowPos( 8 );
- HWND hWndChild = ::GetTopWindow( hWnd );
- for( ; hWndChild != NULL; hWndChild = ::GetNextWindow( hWndChild, GW_HWNDNEXT ) )
- {
- UINT nIDC = _AfxGetDlgCtrlID( hWndChild );
- if( nIDC == nIDLeftOver )
- hWndLeftOver = hWndChild;
- else
- if( nIDC >= nIDFirst
- && nIDC <= nIDLast
- )
- ::SendMessage( hWndChild, WM_SIZEPARENT, 0, (LPARAM)&layout );
- }
- if( nIDLeftOver != 0 && hWndLeftOver != NULL )
- {
- CWnd * pLeftOver = CWnd::FromHandle( hWndLeftOver );
- pLeftOver->CalcWindowRect( &layout.rect );
- ::AfxRepositionWindow( &layout, hWndLeftOver, &layout.rect );
- }
- if( layout.hDWP == NULL
- || ( ! ::EndDeferWindowPos( layout.hDWP ) )
- )
- {
- TRACE0("Warning: DeferWindowPos failed - low system resources.n");
- }
- if( ( ::__EXT_MFC_GetWindowLong(hWnd,GWL_STYLE) & WS_CHILD ) != 0 )
- {
- HWND hWndParent = ::GetParent( hWnd );
- ASSERT( hWndParent != NULL );
- ::ScreenToClient( hWndParent, ((LPPOINT)&rcWnd) );
- ::ScreenToClient( hWndParent, ((LPPOINT)&rcWnd)+1 );
- }
- CRect rcWndAdjusted = rcWnd;
- if( ::SendMessage( hWnd, WM_SIZING, wParamSizingCode, LPARAM(&rcWndAdjusted) ) != 0L )
- rcWnd = rcWndAdjusted;
- ::MoveWindow( hWnd, rcWnd.left, rcWnd.top, rcWnd.Width(), rcWnd.Height(), TRUE );
- SendMessage( hWnd, WM_NCPAINT, 0, 0 );
- CExtPaintManager::stat_PassPaintMessages();
- ::Sleep(1);
- } // if( rcWndCurrent != rcWnd )
- } // if( msg.hwnd == hWnd )
- if( ::IsWindow( hWnd ) )
- continue;
- bStop = true;
- break;
- default:
- if( WM_KEYFIRST <= msg.message
- && msg.message <= WM_KEYLAST
- )
- bStop = true;
- break;
- } // switch( msg.message )
- if( ! ::IsWindow( hWnd ) )
- bStop = true;
- if( bStop )
- break;
- if( ! AfxGetThread()->PumpMessage() )
- {
- PostQuitMessage(0);
- break; // Signal WM_QUIT received
- } // if( !AfxGetThread()->PumpMessage() )
- } // while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
- if( bStop )
- break;
- for( LONG nIdleCounter = 0L;
- ::AfxGetThread()->OnIdle(nIdleCounter);
- nIdleCounter ++
- );
- } // for( ; ! bStop ; )
- ::SetThreadPriority( hCurrentThread, nOldCurrentThreadPriority );
- ::CloseHandle( hCurrentThread );
- ::SetPriorityClass( hProcess, dwOldProcessPriorityClass );
- ::CloseHandle( hProcess );
- if( ::IsWindow( hWnd ) )
- {
- m_bNcFrameImpl_ResizingLoopTracking = false;
- if( ::GetCapture() == hWnd )
- ::ReleaseCapture();
- }
- ::SendMessage( hWnd, WM_EXITSIZEMOVE, 0L, 0L );
- lResult = 0;
- return true;
- } // track resizing loop
- DWORD dw = 0 ;
- if( dw != 0 )
- pWndFrameImpl->ModifyStyle( WS_CAPTION, 0 );
- struct friendly_wnd_t : public CWnd { friend class CExtNcFrameImpl; };
- lResult = ((friendly_wnd_t*)pWndFrameImpl)->DefWindowProc( message, wParam, lParam );
- if( dw != 0 )
- pWndFrameImpl->ModifyStyle( 0, dw );
- return true;
- }
- break;
- case WM_LBUTTONDOWN:
- {
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( pWndFrameImpl->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) )
- pWndFrameImpl->GetParent()->SendMessage( WM_MDIACTIVATE, (WPARAM)pWndFrameImpl->m_hWnd );
- m_nNcFrameImpl_ScTrackedButtonPressed = 0;
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointWnd;
- ::GetCursorPos( &pointWnd );
- pointWnd -= rcWnd.TopLeft();
- m_rcNcFrameImpl_ScClose = NcFrameImpl_GetNcScRect( SC_CLOSE );
- m_rcNcFrameImpl_ScMaximize = NcFrameImpl_GetNcScRect( SC_MAXIMIZE );
- m_rcNcFrameImpl_ScMinimize = NcFrameImpl_GetNcScRect( SC_MINIMIZE );
- m_rcNcFrameImpl_ScHelp = NcFrameImpl_GetNcScRect( SC_CONTEXTHELP );
- if( m_rcNcFrameImpl_ScClose.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_CLOSE;
- else if( m_rcNcFrameImpl_ScMaximize.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_MAXIMIZE;
- else if( m_rcNcFrameImpl_ScMinimize.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_MINIMIZE;
- else if( m_rcNcFrameImpl_ScHelp.PtInRect( pointWnd ) )
- m_nNcFrameImpl_ScTrackedButtonPressed = SC_CONTEXTHELP;
- if( m_nNcFrameImpl_ScTrackedButtonPressed != 0 )
- {
- if( ::GetActiveWindow() != pWndFrameImpl->m_hWnd )
- pWndFrameImpl->SetActiveWindow();
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- HWND hWnd = NULL;
- if( m_pNcFrameImplBridge != NULL
- && ( hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() ) != NULL
- && (! m_rcNcFrameImpl_LastExternalNcHT.IsRectEmpty() )
- )
- ::InvalidateRect( hWnd, m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- if( m_nNcFrameImpl_ScTrackedButtonPressed != 0
- && CWnd::GetCapture() != pWndFrameImpl
- )
- pWndFrameImpl->SetCapture();
- } // if( m_nNcFrameImpl_ScTrackedButtonPressed != 0 )
- }
- break;
- case WM_LBUTTONUP:
- {
- HWND hWnd = NULL;
- if( m_pNcFrameImplBridge != NULL
- && ( hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() ) != NULL
- && (! m_rcNcFrameImpl_LastExternalNcHT.IsRectEmpty() )
- )
- {
- m_nNcFrameImpl_LastExternalNcHT = UINT(-1);
- ::InvalidateRect( hWnd, m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- //::UpdateWindow( hWnd );
- m_rcNcFrameImpl_LastExternalNcHT.SetRect( -1, -1, -1, -1 );
- }
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( m_nNcFrameImpl_ScTrackedButtonPressed == 0 )
- break;
- UINT nSC = m_nNcFrameImpl_ScTrackedButtonPressed;
- if( nSC == SC_MAXIMIZE && pWndFrameImpl->IsZoomed() )
- nSC = SC_RESTORE;
- else if( nSC == SC_MINIMIZE && pWndFrameImpl->IsIconic() )
- nSC = SC_RESTORE;
- m_nNcFrameImpl_ScTrackedButtonHover = m_nNcFrameImpl_ScTrackedButtonPressed = 0;
- m_wndNcFrameImpl_Tip.Hide();
- if( CWnd::GetCapture() == pWndFrameImpl )
- ::ReleaseCapture();
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- CRect rcButton = NcFrameImpl_GetNcScRect( nSC );
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointWnd;
- ::GetCursorPos( &pointWnd );
- pointWnd -= rcWnd.TopLeft();
- if( rcButton.PtInRect(pointWnd) )
- {
- HWND hWndOwn = pWndFrameImpl->GetSafeHwnd();
- ASSERT( hWndOwn != NULL && ::IsWindow(hWndOwn) );
- bool bEnabled = NcFrameImpl_OnQuerySystemCommandEnabled( nSC );
- if( ! bEnabled )
- {
- if( nSC == SC_MAXIMIZE )
- bEnabled = NcFrameImpl_OnQuerySystemCommandEnabled( SC_RESTORE );
- else if( nSC == SC_RESTORE )
- bEnabled = NcFrameImpl_OnQuerySystemCommandEnabled( SC_MAXIMIZE );
- }
- if( bEnabled )
- {
- pWndFrameImpl->SendMessage( WM_SYSCOMMAND, nSC );
- if( ::IsWindow( hWndOwn ) )
- {
- if( nSC == SC_CLOSE )
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- } // if( ::IsWindow( hWndOwn ) )
- }
- } // if( rcButton.PtInRect(pointWnd) )
- }
- lResult = 0;
- return true;
- case WM_MOUSEMOVE:
- {
- HWND hWnd = NULL;
- if( m_pNcFrameImplBridge != NULL
- && ( hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() ) != NULL
- && (! m_rcNcFrameImpl_LastExternalNcHT.IsRectEmpty() )
- )
- ::InvalidateRect( hWnd, m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( m_nNcFrameImpl_ScTrackedButtonHover == 0 )
- break;
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointWnd;
- if( ::GetCursorPos( &pointWnd ) )
- {
- pWndFrameImpl->PostMessage( WM_NCHITTEST, 0, MAKELPARAM( pointWnd.x, pointWnd.y ) );
- pointWnd -= rcWnd.TopLeft();
- }
- else
- pointWnd.x = pointWnd.y = -32767;
- UINT nScTrackedButtonHover = 0;
- if( m_rcNcFrameImpl_ScClose.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_CLOSE;
- else if( m_rcNcFrameImpl_ScMaximize.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_MAXIMIZE;
- else if( m_rcNcFrameImpl_ScMinimize.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_MINIMIZE;
- else if( m_rcNcFrameImpl_ScHelp.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_CONTEXTHELP;
- if( m_nNcFrameImpl_ScTrackedButtonHover != nScTrackedButtonHover )
- {
- m_nNcFrameImpl_ScTrackedButtonHover = nScTrackedButtonHover;
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- if( m_nNcFrameImpl_ScTrackedButtonHover == 0
- && m_nNcFrameImpl_ScTrackedButtonPressed == 0
- )
- {
- if( CWnd::GetCapture() == pWndFrameImpl )
- ::ReleaseCapture();
- m_wndNcFrameImpl_Tip.Hide();
- }
- else
- {
- LPCTSTR strTipText = NcFrameImpl_GetScTipText( m_nNcFrameImpl_ScTrackedButtonHover );
- if( strTipText == NULL || _tcslen(strTipText) == 0 )
- m_wndNcFrameImpl_Tip.Hide();
- else
- {
- CRect rcItem = NcFrameImpl_GetNcScRect( m_nNcFrameImpl_ScTrackedButtonHover );
- rcItem.OffsetRect( rcWnd.TopLeft() );
- m_wndNcFrameImpl_Tip.SetText( strTipText );
- m_wndNcFrameImpl_Tip.Show( pWndFrameImpl, rcItem );
- }
- }
- lResult = 0;
- return true;
- } // if( m_nNcFrameImpl_ScTrackedButtonHover != nScTrackedButtonHover )
- }
- lResult = 0;
- return true;
- case WM_NCMOUSEMOVE:
- if( ! NcFrameImpl_IsSupported() )
- break;
- else
- {
- HWND hWnd = NULL;
- if( m_pNcFrameImplBridge != NULL
- && ( hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() ) != NULL
- && (! m_rcNcFrameImpl_LastExternalNcHT.IsRectEmpty() )
- )
- ::InvalidateRect( hWnd, m_rcNcFrameImpl_LastExternalNcHT, TRUE );
- if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- {
- if( wParam == HTCAPTION || wParam == HTSYSMENU )
- {
- hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CPoint ptCursor;
- ::GetCursorPos( &ptCursor );
- ::ScreenToClient( hWnd, &ptCursor );
- CExtControlBar * pBar = DYNAMIC_DOWNCAST( CExtControlBar, CWnd::FromHandlePermanent( hWnd ) );
- if( pBar != NULL )
- {
- if( pBar->_OnMouseMoveMsg( 0, ptCursor ) )
- {
- lResult = 0L;
- return true;
- }
- }
- else
- {
- lResult = ::SendMessage( hWnd, WM_MOUSEMOVE, 0, MAKELPARAM( ptCursor.x, ptCursor.y ) );
- return true;
- }
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- } // if( wParam == HTCAPTION || wParam == HTSYSMENU )
- break;
- } // if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- if( NcFrameImpl_IsForceEmpty() )
- break;
- if( m_rcNcFrameImpl_ScClose.IsRectEmpty() )
- NcFrameImpl_ReCacheScButtonRects();
- CRect rcWnd;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- CPoint pointWnd;
- if( ::GetCursorPos( &pointWnd ) )
- {
- pWndFrameImpl->PostMessage( WM_NCHITTEST, 0, MAKELPARAM( pointWnd.x, pointWnd.y ) );
- pointWnd -= rcWnd.TopLeft();
- }
- else
- pointWnd.x = pointWnd.y = -32767;
- UINT nScTrackedButtonHover = 0;
- if( m_rcNcFrameImpl_ScClose.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_CLOSE;
- else if( m_rcNcFrameImpl_ScMaximize.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_MAXIMIZE;
- else if( m_rcNcFrameImpl_ScMinimize.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_MINIMIZE;
- else if( m_rcNcFrameImpl_ScHelp.PtInRect( pointWnd ) )
- nScTrackedButtonHover = SC_CONTEXTHELP;
- if( m_nNcFrameImpl_ScTrackedButtonHover != nScTrackedButtonHover )
- {
- m_nNcFrameImpl_ScTrackedButtonHover = nScTrackedButtonHover;
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- if( m_nNcFrameImpl_ScTrackedButtonHover != 0 )
- {
- if( CWnd::GetCapture() != pWndFrameImpl )
- pWndFrameImpl->SetCapture();
- LPCTSTR strTipText = NcFrameImpl_GetScTipText( m_nNcFrameImpl_ScTrackedButtonHover );
- if( strTipText == NULL || _tcslen(strTipText) == 0 )
- m_wndNcFrameImpl_Tip.Hide();
- else
- {
- CRect rcItem = NcFrameImpl_GetNcScRect( m_nNcFrameImpl_ScTrackedButtonHover );
- rcItem.OffsetRect( rcWnd.TopLeft() );
- m_wndNcFrameImpl_Tip.SetText( strTipText );
- m_wndNcFrameImpl_Tip.Show( pWndFrameImpl, rcItem );
- }
- }
- else
- m_wndNcFrameImpl_Tip.Hide();
- } // if( m_nNcFrameImpl_ScTrackedButtonHover != nScTrackedButtonHover )
- }
- lResult = 0;
- return true;
- case WM_SYSCOMMAND:
- {
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- CExtPopupMenuWnd::CancelMenuTracking();
- CWnd::CancelToolTips();
- CExtPopupMenuSite::g_DefPopupMenuSite.GetTip().Hide();
- m_wndNcFrameImpl_Tip.Hide();
- if( m_wndNcFrameImpl_Tip.GetSafeHwnd() != NULL )
- m_wndNcFrameImpl_Tip.DestroyWindow();
- UINT nSC = UINT( wParam );
- if( nSC == SC_SIZE || nSC == SC_NEXTWINDOW || nSC == SC_PREVWINDOW )
- break;
- if( ! NcFrameImpl_OnQuerySystemCommandEnabled( nSC ) )
- {
- lResult = 0;
- return true;
- }
- pWndFrameImpl->ModifyStyle( 0, WS_CAPTION|WS_BORDER, 0 );
- if( NcFrameImpl_OnQueryQuickWindowPlacement() )
- {
- if( nSC == SC_MAXIMIZE
- || nSC == SC_MINIMIZE
- || nSC == SC_RESTORE
- )
- {
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- if( GetWindowPlacement( &_wp ) )
- {
- switch( nSC )
- {
- case SC_MAXIMIZE:
- _wp.showCmd = SW_SHOWMAXIMIZED;
- break;
- case SC_MINIMIZE:
- m_nNcFrameImpl_LastShowCmd = _wp.showCmd;
- _wp.showCmd = SW_SHOWMINIMIZED;
- break;
- case SC_RESTORE:
- _wp.showCmd =
- ( m_nNcFrameImpl_LastShowCmd != SW_HIDE )
- ? m_nNcFrameImpl_LastShowCmd
- : SW_RESTORE // SW_SHOWNORMAL
- ;
- m_nNcFrameImpl_LastShowCmd = SW_HIDE;
- if( _wp.showCmd == SW_SHOWMAXIMIZED && pWndFrameImpl->IsZoomed() )
- _wp.showCmd = SW_RESTORE;
- break;
- #ifdef _DEBUG
- default:
- ASSERT( FALSE );
- break;
- #endif // _DEBUG
- } // switch( nSC )
- SetWindowPlacement( &_wp );
- } // if( GetWindowPlacement( hWndOwn, &_wp ) )
- lResult = 0;
- return true;
- }
- } // if( NcFrameImpl_OnQueryQuickWindowPlacement() )
- if( message == WM_SYSCOMMAND && nSC == SC_MINIMIZE && pWndFrameImpl->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) )
- { // fix for minimizing of maximized MDI child frame
- HWND hWndMdiClient = ::GetParent( pWndFrameImpl->m_hWnd );
- BOOL bMax = FALSE;
- HWND hWndActiveMdiChildFrame = (HWND) ::SendMessage( hWndMdiClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMax );
- if( hWndActiveMdiChildFrame != NULL && bMax )
- {
- bool bNextAvailable = false;
- HWND hWnd = ::GetWindow( hWndActiveMdiChildFrame, GW_HWNDNEXT );
- for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
- {
- __EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( hWnd, GWL_STYLE );
- if( ( dwWndStyle & WS_VISIBLE ) == 0 )
- continue;
- if( IsIconic( hWnd ) )
- continue;
- bNextAvailable = true;
- break;
- }
- if( ! bNextAvailable )
- {
- hWnd = ::GetWindow( hWndActiveMdiChildFrame, GW_HWNDPREV );
- for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDPREV ) )
- {
- __EXT_MFC_LONG_PTR dwWndStyle = ::__EXT_MFC_GetWindowLong( hWnd, GWL_STYLE );
- if( ( dwWndStyle & WS_VISIBLE ) == 0 )
- continue;
- if( IsIconic( hWnd ) )
- continue;
- bNextAvailable = true;
- break;
- }
- }
- if( bNextAvailable )
- {
- CRect rcSurface;
- ::GetClientRect( hWndMdiClient, &rcSurface );
- HWND hWndSurface =
- ::CreateWindowEx(
- 0, _T("Static"), _T(""), WS_CHILD, rcSurface.left, rcSurface.top, rcSurface.Width(), rcSurface.Height(),
- hWndMdiClient, (HMENU)NULL, ::AfxGetInstanceHandle(), NULL
- );
- if( hWndSurface != NULL )
- {
- ::EnableWindow( hWndSurface, FALSE );
- ::ShowWindow( hWndSurface, SW_SHOWNOACTIVATE );
- }
- ::SendMessage( hWndMdiClient, WM_MDINEXT, WPARAM(pWndFrameImpl->m_hWnd), 0L );
- struct friendly_wnd_t : public CWnd { friend class CExtNcFrameImpl; };
- lResult = ((friendly_wnd_t*)pWndFrameImpl)->DefWindowProc( message, wParam, lParam );
- hWndActiveMdiChildFrame = (HWND) ::SendMessage( hWndMdiClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMax );
- if( hWndActiveMdiChildFrame != NULL )
- {
- ::SendMessage( hWndMdiClient, WM_MDIMAXIMIZE, WPARAM(hWndActiveMdiChildFrame), 0L );
- ::SendMessage( hWndMdiClient, WM_MDIACTIVATE, WPARAM(hWndActiveMdiChildFrame), 0L );
- }
- ::DestroyWindow( hWndSurface );
- return true;
- } // if( bNextAvailable )
- } // if( hWndActiveMdiChildFrame != NULL && bMax )
- } // fix for minimizing of maximized MDI child frame
- if( m_bNcFrameImpl_IsEnabled
- && ( ! m_bNcFrameImpl_RestoreEnabledState )
- && nSC != SC_MOVE
- && nSC != SC_SIZE
- && pWndFrameImpl->IsKindOf( RUNTIME_CLASS( CMDIChildWnd ) )
- )
- m_bNcFrameImpl_RestoreEnabledState = true;
- if( nSC != SC_CLOSE )
- NcFrameImpl_NcLock( true );
- }
- break;
- case WM_DESTROY:
- case WM_NCDESTROY:
- m_bNcFrameImpl_DwmSurfaceInitializationComplete = false;
- m_bNcFrameImpl_CreatePassed = false;
- case WM_SETTINGCHANGE:
- NcFrameImpl_MapHtRects_Clean();
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- if( wParam == SPI_SETWORKAREA )
- {
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- _wp.length = sizeof(WINDOWPLACEMENT);
- if( GetWindowPlacement( _wp ) && _wp.showCmd == SW_SHOWMAXIMIZED )
- {
- CExtPaintManager::monitor_parms_t _mp;
- CExtPaintManager::stat_GetMonitorParms( _mp, pWndFrameImpl );
- WINDOWPLACEMENT _wpAdjust;
- ::memcpy( &_wpAdjust, &_wp, sizeof(WINDOWPLACEMENT) );
- _wpAdjust.showCmd = SW_SHOWNORMAL; // SW_RESTORE;
- // pWndFrameImpl->GetWindowRect( &_wpAdjust.rcNormalPosition );
- ::CopyRect( &_wpAdjust.rcNormalPosition, &_mp.m_rcWorkArea );
- _wpAdjust.ptMaxPosition.x = _wpAdjust.ptMaxPosition.x = _wpAdjust.rcNormalPosition.left;
- _wpAdjust.ptMaxPosition.y = _wpAdjust.ptMaxPosition.y = _wpAdjust.rcNormalPosition.top;
- SetWindowPlacement( _wpAdjust );
- SetWindowPlacement( _wp );
- //NcFrameImpl_RecalcNcFrame();
- }
- }
- break;
- case WM_DISPLAYCHANGE:
- NcFrameImpl_MapHtRects_Clean();
- break;
- case WM_GETMINMAXINFO:
- if( m_bNcFrameImpl_ResizingLoopTracking || m_bNcFrameImpl_MovingLoopTracking )
- break;
- if( NcFrameImpl_IsSupported() )
- {
- LPMINMAXINFO pMMI = (LPMINMAXINFO)lParam;
- ASSERT( pMMI != NULL );
- struct friendly_wnd_t : public CWnd { friend class CExtNcFrameImpl; };
- ((friendly_wnd_t*)pWndFrameImpl)->DefWindowProc( message, wParam, lParam );
- bool bOK = NcFrameImpl_GetMinMaxInfo( pMMI );
- ::memcpy( &m_NcFrameImpl_MinMaxInfo_Cache, pMMI, sizeof(MINMAXINFO) );
- if( bOK )
- return true;
- } // if( NcFrameImpl_IsSupported() )
- break;
- } // switch( message )
- return false;
- }
- bool CExtNcFrameImpl::NcFrameImpl_OnQuerySystemCommandEnabled(
- UINT nSystemCommandID
- )
- {
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl == NULL )
- return false;
- if( nSystemCommandID == SC_CLOSE )
- {
- CMenu * pSysMenu = pWndFrameImpl->GetSystemMenu( FALSE );
- if( pSysMenu == NULL )
- return false;
- UINT _nSystemCommandID = nSystemCommandID;
- UINT nMenuItemState =
- pSysMenu->GetMenuState( _nSystemCommandID, MF_BYCOMMAND );
- if( nMenuItemState == 0xFFFFFFFF )
- return false;
- if( (nMenuItemState&(MF_DISABLED|MF_GRAYED)) != 0 )
- return false;
- }
- DWORD dwStyle = pWndFrameImpl->GetStyle();
- if( nSystemCommandID == SC_MINIMIZE )
- {
- if( (dwStyle&WS_MINIMIZEBOX) == 0 )
- return false;
- }
- if( nSystemCommandID == SC_MAXIMIZE )
- {
- if( (dwStyle&WS_MAXIMIZEBOX) == 0 )
- return false;
- }
- if( nSystemCommandID == SC_RESTORE || nSystemCommandID == SC_MAXIMIZE )
- {
- MINMAXINFO _mmi;
- // ::memset( &_mmi, 0, sizeof(MINMAXINFO) );
- // CExtPaintManager::monitor_parms_t _mp;
- // CExtPaintManager::stat_GetMonitorParms( _mp, pWndFrameImpl );
- // _mmi.ptMaxPosition.x = _mp.m_rcWorkArea.left;
- // _mmi.ptMaxPosition.y = _mp.m_rcWorkArea.top;
- // _mmi.ptMaxTrackSize.x = _mp.m_rcWorkArea.Width(); // ::GetSystemMetrics( SM_CXMAXTRACK );
- // _mmi.ptMaxTrackSize.y = _mp.m_rcWorkArea.Height(); // ::GetSystemMetrics( SM_CYMAXTRACK );
- // _mmi.ptMinTrackSize.x = ::GetSystemMetrics( SM_CXMINTRACK );
- // _mmi.ptMinTrackSize.y = ::GetSystemMetrics( SM_CYMINTRACK );
- // _mmi.ptMaxSize.x = _mmi.ptMaxTrackSize.x;
- // _mmi.ptMaxSize.y = _mmi.ptMaxTrackSize.y;
- // if( pWndFrameImpl->SendMessage( WM_GETMINMAXINFO, 0, LPARAM(&_mmi) ) == 0 )
- ::memcpy( &_mmi, &m_NcFrameImpl_MinMaxInfo_Cache, sizeof(MINMAXINFO) );
- NcFrameImpl_GetMinMaxInfo( &_mmi );
- {
- if( nSystemCommandID == SC_RESTORE )
- {
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- _wp.length = sizeof(WINDOWPLACEMENT);
- GetWindowPlacement( &_wp );
- if( _wp.showCmd == SW_SHOWMINIMIZED
- || _wp.showCmd == SW_SHOWMINNOACTIVE
- || _wp.showCmd == SW_RESTORE
- || _wp.showCmd == SW_SHOWMAXIMIZED
- )
- return true;
- }
- if( _mmi.ptMinTrackSize.x >= _mmi.ptMaxTrackSize.x
- || _mmi.ptMinTrackSize.y >= _mmi.ptMaxTrackSize.y
- )
- return false;
- }
- }
- return true;
- }
- CExtPaintManager * CExtNcFrameImpl::NcFrameImpl_GetPM()
- {
- return m_BridgeNC.PmBridge_GetPM();
- }
- CExtPaintManager * CExtNcFrameImpl::NcFrameImpl_GetPM() const
- {
- return
- ( const_cast < CExtNcFrameImpl * > ( this ) )
- -> NcFrameImpl_GetPM();
- }
- CExtNcFrameImpl * CExtNcFrameImpl::NcFrameImpl_FindInstance(
- HWND hWnd,
- IExtNcFrameImplBridge * pNcFrameImplBridge // = NULL
- )
- {
- for( ; hWnd != NULL && ::IsWindow( hWnd ); hWnd = ::GetParent( hWnd ) )
- {
- if( ( ::__EXT_MFC_GetWindowLong( hWnd, GWL_STYLE ) & WS_CHILD ) != 0 )
- continue;
- CExtNcFrameImpl * pExtNcFrameImpl = NULL;
- ::SendMessage(
- hWnd,
- g_nMsgFindExtNcFrameImpl,
- WPARAM(&pExtNcFrameImpl),
- LPARAM(pNcFrameImplBridge)
- );
- if( pExtNcFrameImpl != NULL )
- return pExtNcFrameImpl;
- } // for( ; hWnd != NULL && ::IsWindow( hWnd ); hWnd = ::GetParent( hWnd ) )
- return NULL;
- }
- void CExtNcFrameImpl::NcFrameImpl_CheckCursor(
- CPoint pointScreen,
- LPARAM nHT,
- bool bCheckWindowFromPoint // = true
- )
- {
- if( (! NcFrameImpl_IsSupported() )
- || NcFrameImpl_IsDwmBased()
- || (! ::GetCursorPos(&pointScreen) ) // reset
- )
- {
- m_nNcFrameImpl_LastCheckCursorHT = HTNOWHERE;
- m_ptNcFrameImpl_LastCheckCursor.x = m_ptNcFrameImpl_LastCheckCursor.y = -32767;
- return;
- }
- HWND hWndOwn = NcFrameImpl_OnQueryHWND();
- if( hWndOwn == NULL
- || ( bCheckWindowFromPoint
- && ::WindowFromPoint( pointScreen ) != hWndOwn
- )
- )
- {
- m_nNcFrameImpl_LastCheckCursorHT = HTNOWHERE;
- m_ptNcFrameImpl_LastCheckCursor.x = m_ptNcFrameImpl_LastCheckCursor.y = -32767;
- return;
- }
- if( m_ptNcFrameImpl_LastCheckCursor == pointScreen
- && m_nNcFrameImpl_LastCheckCursorHT == nHT
- )
- return;
- m_ptNcFrameImpl_LastCheckCursor = pointScreen;
- m_nNcFrameImpl_LastCheckCursorHT = nHT;
- ::SendMessage( hWndOwn, WM_SETCURSOR, WPARAM(hWndOwn), nHT );
- }
- void CExtNcFrameImpl::NcFrameImpl_PostWindowProc( LRESULT & lResult, UINT message, WPARAM wParam, LPARAM lParam )
- {
- lResult;
- switch( message )
- {
- case WM_CAPTURECHANGED:
- {
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- CWnd * pWndFrameImpl = (CWnd *)NcFrameImpl_GetFrameWindow();
- if( ((HWND)lParam) != pWndFrameImpl->m_hWnd )
- pWndFrameImpl->ModifyStyle( 0, WS_CAPTION|WS_BORDER, 0 );
- }
- break;
- case WM_NCPAINT:
- if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL && ::IsWindow( hWnd ) )
- {
- CWnd * pWndFrameImpl = (CWnd *)NcFrameImpl_GetFrameWindow();
- ASSERT_VALID( pWndFrameImpl );
- CWindowDC dcWnd( pWndFrameImpl );
- CRect rcWnd, rcClient;
- pWndFrameImpl->GetWindowRect( &rcWnd );
- pWndFrameImpl->GetClientRect( &rcClient );
- pWndFrameImpl->ClientToScreen( &rcClient );
- rcClient.OffsetRect( -rcWnd.TopLeft() );
- rcWnd.OffsetRect( -rcWnd.TopLeft() );
- dcWnd.ExcludeClipRect( &rcClient );
- CExtMemoryDC dc( &dcWnd, &rcWnd );
- dc.FillSolidRect( &rcWnd, RGB(0,0,0) );
- CPoint ptViewPortOffset(
- ::GetSystemMetrics( SM_CXSIZEFRAME ),
- ::GetSystemMetrics( SM_CYCAPTION )
- - NcFrameImpl_GetPM()->NcFrame_GetCaptionHeight( true, pWndFrameImpl )
- + ::GetSystemMetrics( SM_CYSIZEFRAME )
- );
- dc.OffsetViewportOrg( ptViewPortOffset.x, ptViewPortOffset.y );
- ::SendMessage( hWnd, WM_PRINTCLIENT, WPARAM(dc.m_hDC), PRF_CLIENT );
- dc.OffsetViewportOrg( -ptViewPortOffset.x, -ptViewPortOffset.y );
- } // if( hWnd != NULL && ::IsWindow( hWnd ) )
- } // if( NcFrameImpl_IsDwmCaptionReplacement() && m_pNcFrameImplBridge != NULL )
- break;
- case 0x031E: // WM_DWMCOMPOSITIONCHANGED
- {
- CExtPaintManager * pPM = NcFrameImpl_GetPM();
- ASSERT_VALID( pPM );
- m_BridgeNC.PmBridge_OnPaintManagerChanged( pPM );
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl->GetSafeHwnd() != NULL )
- {
- if( pWndFrameImpl->IsKindOf( RUNTIME_CLASS(CFrameWnd) ) )
- ((CFrameWnd*)pWndFrameImpl)->RecalcLayout();
- BOOL bDwmIsCompositionEnabled = FALSE;
- if( m_pNcFrameImplBridge != NULL
- && m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd() != NULL
- && ( ! pWndFrameImpl->IsZoomed() )
- && g_PaintManager.m_DWM.DwmIsCompositionEnabled( & bDwmIsCompositionEnabled ) == S_OK
- && ( ! bDwmIsCompositionEnabled )
- )
- CWnd::GetDesktopWindow()->RedrawWindow(
- NULL, NULL,
- RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN
- );
- }
- }
- break;
- case WM_CREATE:
- m_bNcFrameImpl_CreatePassed = true;
- break;
- case WM_PRINT:
- case WM_PRINTCLIENT:
- {
- CWnd * pWndFrameImpl = (CWnd *)NcFrameImpl_GetFrameWindow();
- ASSERT_VALID( pWndFrameImpl );
- CDC dc;
- dc.Attach( (HDC)wParam );
- CRect rcRgnWnd, rcRgnClient;
- pWndFrameImpl->GetWindowRect( &rcRgnWnd );
- pWndFrameImpl->GetClientRect( &rcRgnClient );
- if( (lParam&PRF_NONCLIENT) != 0
- && NcFrameImpl_IsSupported()
- && ( ! NcFrameImpl_IsDwmBased() )
- )
- {
- CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
- pWndFrameImpl->ClientToScreen( &rcClient );
- rcClient.OffsetRect( -rcWnd.TopLeft() );
- rcWnd.OffsetRect( -rcWnd.TopLeft() );
- CRgn rgnWnd;
- if( rgnWnd.CreateRectRgnIndirect(&rcWnd) )
- dc.SelectClipRgn( &rgnWnd );
- dc.ExcludeClipRect( &rcClient );
- NcFrameImpl_OnNcPaint( dc );
- dc.SelectClipRgn( NULL );
- }
- if( (lParam&PRF_CHILDREN) != 0 )
- CExtPaintManager::stat_PrintChildren(
- pWndFrameImpl->m_hWnd,
- message,
- dc.GetSafeHdc(),
- lParam,
- false
- );
- dc.Detach();
- } // if( NcFrameImpl_IsSupported() && ( ! NcFrameImpl_IsDwmBased() ) )
- break;
- case WM_NCLBUTTONDBLCLK:
- if( NcFrameImpl_IsDwmBased() )
- break;
- m_bNcFrameImpl_RestoreBorder = false;
- break;
- case WM_SIZE:
- if( ! NcFrameImpl_IsSupported() )
- break;
- m_nNcFrameImpl_ScTrackedButtonPressed = 0;
- m_nNcFrameImpl_ScTrackedButtonHover = 0;
- NcFrameImpl_MapHtRects_Clean();
- if( ! NcFrameImpl_IsDwmBased() )
- {
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( (pWndFrameImpl->GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- {
- m_bNcFrameImpl_DelatayedFrameRecalc = false;
- NcFrameImpl_SetupRgn( NULL );
- }
- }
- break;
- case WM_WINDOWPOSCHANGING:
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- if( ! NcFrameImpl_IsForceEmpty() )
- {
- if( m_bNcFrameImpl_AssigningRGN )
- break;
- LPWINDOWPOS lpWindowPos =
- reinterpret_cast < LPWINDOWPOS > (lParam);
- ASSERT( lpWindowPos != NULL );
- //lpWindowPos->flags |= SWP_FRAMECHANGED;
- m_bNcFrameImpl_DelatayedFrameRecalc =
- ( ( lpWindowPos->flags & SWP_FRAMECHANGED ) == 0 )
- ? true : false;
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
- && (pWndFrameImpl->GetStyle()&WS_MAXIMIZE) != 0
- )
- {
- m_bNcFrameImpl_AssigningRGN = true;
- pWndFrameImpl->SetWindowRgn( NULL, FALSE );
- m_bNcFrameImpl_AssigningRGN = false;
- }
- else
- NcFrameImpl_SetupRgn( (WINDOWPOS *)lParam );
- }
- break;
- case WM_WINDOWPOSCHANGED:
- {
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- m_bNcFrameImpl_DelatayedFrameRecalc = false;
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl->IsKindOf(RUNTIME_CLASS(CMDIChildWnd))
- && pWndFrameImpl->IsZoomed()
- )
- {
- HWND hWndMdiClient = ::GetParent( pWndFrameImpl->m_hWnd );
- CRect rcClient;
- ::GetClientRect( hWndMdiClient, &rcClient );
- ::SendMessage( hWndMdiClient, WM_SIZE, SIZE_RESTORED, MAKELPARAM( rcClient.Width(), rcClient.Height() ) );
- //NcFrameImpl_SetupRgn();
- }
- if( ! m_bNcFrameImpl_RestoreEnabledState )
- break;
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- if( m_pNcFrameImplBridge != NULL )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL )
- {
- ::InvalidateRect( hWnd, NULL, TRUE );
- ::UpdateWindow( hWnd );
- }
- }
- }
- // continuing switch ...
- case WM_SYSCOMMAND:
- {
- if( ! NcFrameImpl_IsSupported() )
- break;
- if( NcFrameImpl_IsDwmBased() )
- break;
- UINT nSC = UINT( wParam );
- if( nSC == SC_SIZE || nSC == SC_NEXTWINDOW || nSC == SC_PREVWINDOW )
- break;
- CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl->GetSafeHwnd() != NULL
- && m_bNcFrameImpl_RestoreEnabledState
- )
- m_bNcFrameImpl_IsEnabled = true;
- m_bNcFrameImpl_RestoreEnabledState = false;
- if( message == WM_SYSCOMMAND && nSC != SC_CLOSE )
- NcFrameImpl_NcLock( false );
- if( pWndFrameImpl->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
- && (pWndFrameImpl->GetStyle()&WS_MAXIMIZE) != 0
- )
- {
- m_bNcFrameImpl_AssigningRGN = true;
- pWndFrameImpl->SetWindowRgn( NULL, TRUE );
- m_bNcFrameImpl_AssigningRGN = false;
- ((CMDIChildWnd*)pWndFrameImpl)->RecalcLayout();
- pWndFrameImpl->GetParent()->PostMessage( WM_MDIREFRESHMENU );
- }
- else
- NcFrameImpl_SetupRgn();
- if( pWndFrameImpl->IsWindowVisible() )
- {
- if( message == WM_SYSCOMMAND && ( nSC == SC_MAXIMIZE || nSC == SC_RESTORE ) )
- {
- if( nSC == SC_MAXIMIZE )
- {
- CMDIChildWnd * pWndMdiChild = DYNAMIC_DOWNCAST( CMDIChildWnd, pWndFrameImpl );
- if( pWndMdiChild != NULL )
- {
- CRect rcWnd;
- pWndMdiChild->GetWindowRect( &rcWnd );
- pWndMdiChild->SendMessage( WM_NCHITTEST, MAKELPARAM( rcWnd.left, rcWnd.top ) );
- CWnd * pWndMC = pWndFrameImpl->GetParent();
- CRect rcMC;
- pWndMC->GetWindowRect( &rcMC );
- pWndMC->SendMessage( WM_SIZE, SIZE_RESTORED, MAKELPARAM(rcMC.Width(),rcMC.Height()) );
- pWndMC->SendMessage( WM_MDIACTIVATE, (WPARAM)pWndFrameImpl->m_hWnd );
- }
- }
- pWndFrameImpl->RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME|RDW_ALLCHILDREN );
- }
- else
- pWndFrameImpl->SendMessage( WM_NCPAINT );
- }
- if( message == WM_SYSCOMMAND
- && nSC == SC_RESTORE
- && m_pNcFrameImplBridge != NULL
- )
- {
- HWND hWnd = m_pNcFrameImplBridge->NcFrameImplBridge_GetSafeHwnd();
- if( hWnd != NULL )
- {
- CWnd * pWndPermanent = CWnd::FromHandlePermanent( hWnd );
- if( pWndPermanent != NULL )
- {
- CExtToolControlBar * pBar = DYNAMIC_DOWNCAST( CExtToolControlBar, pWndPermanent );
- if( pBar != NULL )
- {
- pBar->_RibbonPageRslaResetStateData();
- pBar->_RecalcLayoutImpl();
- }
- }
- }
- }
- } // case WM_SYSCOMMAND
- break;
- } // switch( message )
- }
- bool CExtNcFrameImpl::NcFrameImpl_OnQueryQuickWindowPlacement() const
- {
- if( ! NcFrameImpl_IsSupported() )
- return false;
- if( g_PaintManager.m_DWM.IsCompositionEnabled() )
- return false;
- if( m_bNcFrameImpl_QuickWindowPlacement )
- return true;
- const CWnd * pWndFrameImpl = NcFrameImpl_GetFrameWindow();
- if( pWndFrameImpl != NULL && pWndFrameImpl->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) ) )
- return true;
- return false;
- }
- bool CExtNcFrameImpl::NcFrameImpl_RecalcNcFrame()
- {
- if( NcFrameImpl_IsNcLocked() )
- return false;
- HWND hWndOwn = NcFrameImpl_OnQueryHWND();
- if( hWndOwn == NULL )
- return false;
- ASSERT( ::IsWindow( hWndOwn ) );
- ::SetWindowPos(
- hWndOwn, NULL, 0, 0, 0, 0,
- SWP_FRAMECHANGED
- |SWP_NOACTIVATE
- |SWP_NOZORDER
- |SWP_NOOWNERZORDER
- |SWP_NOMOVE
- |SWP_NOSIZE
- );
- return true;
- }
- void CExtNcFrameImpl::PreSubclassWindow()
- {
- ::memset( &m_NcFrameImpl_MinMaxInfo_Cache, 0, sizeof(MINMAXINFO) );
- HWND hWndOwn = NcFrameImpl_OnQueryHWND();
- ASSERT( hWndOwn != NULL && ::IsWindow( hWndOwn ) );
- m_dwNcFrameImpl_StyleInitial = ::__EXT_MFC_GetWindowLong( hWndOwn, GWL_STYLE );
- m_dwNcFrameImpl_StyleExInitial = ::__EXT_MFC_GetWindowLong( hWndOwn, GWL_EXSTYLE );
- if( m_bNcFrameImpl_IsDwmBased && (m_dwNcFrameImpl_StyleInitial&WS_CHILD) != 0 )
- m_bNcFrameImpl_IsDwmBased = false;
- if( m_bNcFrameImpl_IsDwmBased )
- m_bNcFrameImpl_Moving = m_bNcFrameImpl_Resizing = false;
- if( (m_dwNcFrameImpl_StyleInitial&(WS_BORDER|WS_CAPTION)) != 0
- && NcFrameImpl_IsSupported()
- )
- NcFrameImpl_DelayRgnAdjustment();
- NcFrameImpl_MapHtRects_Clean();
- NcFrameImpl_RecalcNcFrame();
- { // BLOCK: adjust MDI client area styles
- HWND hWndMdiClient = CExtControlBar::stat_FindMdiClientHWND( hWndOwn );
- if( hWndMdiClient != NULL )
- {
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_STYLE );
- if( (dwStyle&WS_BORDER) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_STYLE, dwStyle&(~(WS_BORDER)) );
- __EXT_MFC_LONG_PTR dwStyleEx = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_EXSTYLE );
- if( (dwStyleEx&(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_EXSTYLE, (dwStyleEx&(~(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)))|WS_EX_CLIENTEDGE );
- }
- } // BLOCK: adjust MDI client area styles
- m_bNcFrameImpl_ResizingLoopTracking = m_bNcFrameImpl_MovingLoopTracking = false;
- }
- void CExtNcFrameImpl::PostNcDestroy()
- {
- ::memset( &m_NcFrameImpl_MinMaxInfo_Cache, 0, sizeof(MINMAXINFO) );
- m_pNcFrameImplBridge = NULL;
- NcFrameImpl_DelayRgnAdjustment();
- m_nNcFrameImpl_LastCheckCursorHT = HTNOWHERE;
- m_ptNcFrameImpl_LastCheckCursor.x = m_ptNcFrameImpl_LastCheckCursor.y = -32767;
- m_iconNcFrameImpl_QueryCache.Empty();
- m_bNcFrameImpl_NcInitPassed = false;
- m_bNcFrameImpl_ResizingLoopTracking = m_bNcFrameImpl_MovingLoopTracking = false;
- }
- IMPLEMENT_CExtPmBridge_MEMBERS( CExtNcFrameWatchMDIMF );
- UINT CExtNcFrameWatchMDIMF::g_nMsgSurface =
- ::RegisterWindowMessage( _T("CExtNcFrameWatchMDIMF::g_nMsgSurface") );
- CExtNcFrameWatchMDIMF::CExtNcFrameWatchMDIMF()
- : m_pNcFrameImpl( NULL )
- , m_hWndSurface( NULL )
- {
- PmBridge_Install();
- }
- CExtNcFrameWatchMDIMF::~CExtNcFrameWatchMDIMF()
- {
- PmBridge_Uninstall();
- if( m_hWndSurface != NULL )
- ::DestroyWindow( m_hWndSurface );
- }
- void CExtNcFrameWatchMDIMF::_Surface( bool bForward )
- {
- CWnd * pWndFrameImpl = m_pNcFrameImpl->NcFrameImpl_GetFrameWindow();
- if( bForward )
- {
- if( pWndFrameImpl->GetSafeHwnd() == NULL )
- return;
- if( m_hWndSurface == NULL )
- {
- HWND hWndParent = pWndFrameImpl->GetSafeHwnd();
- ASSERT( hWndParent != NULL );
- hWndParent = CExtControlBar::stat_FindMdiClientHWND( hWndParent );
- ASSERT( hWndParent != NULL );
- CRect rcSurface;
- ::GetClientRect( hWndParent, &rcSurface );
- m_hWndSurface =
- ::CreateWindowEx(
- 0, _T("Static"), _T(""), WS_CHILD, rcSurface.left, rcSurface.top, rcSurface.Width(), rcSurface.Height(),
- hWndParent, (HMENU)NULL, ::AfxGetInstanceHandle(), NULL
- );
- if( m_hWndSurface != NULL )
- {
- ::EnableWindow( m_hWndSurface, FALSE );
- ::ShowWindow( m_hWndSurface, SW_SHOWNOACTIVATE );
- } // if( m_hWndSurface != NULL )
- } // if( m_hWndSurface == NULL )
- } // if( bForward )
- else
- {
- if( m_hWndSurface != NULL )
- {
- ::DestroyWindow( m_hWndSurface );
- m_hWndSurface = NULL;
- } // if( m_hWndSurface != NULL )
- } // else from if( bForward )
- }
- static CWnd * stat_pWndInit = NULL;
- bool CExtNcFrameWatchMDIMF::OnHookWndMsg(
- LRESULT & lResult,
- HWND hWndHooked,
- UINT nMessage,
- WPARAM & wParam,
- LPARAM & lParam
- )
- {
- if( m_pNcFrameImpl != NULL )
- {
- switch( nMessage )
- {
- case WM_MDIDESTROY:
- case WM_MDINEXT:
- case WM_MDIICONARRANGE:
- case WM_MDITILE:
- case WM_MDICASCADE:
- case WM_MDIACTIVATE:
- //case WM_MDICREATE:
- {
- _Surface( true );
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong( hWndHooked, GWL_STYLE );
- if( (dwStyle&WS_CLIPCHILDREN|WS_CLIPCHILDREN) == 0 )
- ::__EXT_MFC_SetWindowLong( hWndHooked, GWL_STYLE, dwStyle|WS_CLIPCHILDREN||WS_CLIPCHILDREN );
- { // BLOCK: adjust MDI client area styles
- HWND hWndMdiClient = CExtControlBar::stat_FindMdiClientHWND( hWndHooked );
- if( hWndMdiClient != NULL )
- {
- __EXT_MFC_LONG_PTR dwStyle = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_STYLE );
- if( (dwStyle&WS_BORDER) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_STYLE, dwStyle&(~(WS_BORDER)) );
- __EXT_MFC_LONG_PTR dwStyleEx = ::__EXT_MFC_GetWindowLong( hWndMdiClient, GWL_EXSTYLE );
- if( (dwStyleEx&(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) != 0 )
- ::__EXT_MFC_SetWindowLong( hWndMdiClient, GWL_EXSTYLE, (dwStyleEx&(~(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)))|WS_EX_CLIENTEDGE );
- }
- } // BLOCK: adjust MDI client area styles
- if( nMessage == WM_MDICASCADE || nMessage == WM_MDITILE )
- {
- BOOL bMax = FALSE;
- HWND hWndActiveMdiChildFrame = (HWND)
- ::SendMessage(
- hWndHooked,
- WM_MDIGETACTIVE,
- 0,
- (LPARAM)&bMax
- );
- if( hWndActiveMdiChildFrame != NULL && bMax )
- ::SendMessage(
- hWndHooked,
- WM_MDIRESTORE,
- (WPARAM)hWndActiveMdiChildFrame,
- 0
- );
- } // if( nMessage == WM_MDICASCADE || nMessage == WM_MDITILE )
- switch( nMessage )
- {
- case WM_MDIICONARRANGE:
- {
- CList < HWND, HWND > _listWindowsToSkip;
- if( m_hWndSurface != NULL )
- _listWindowsToSkip.AddTail( m_hWndSurface );
- CExtNcFrameImpl::stat_MDI_ArrangeIconic( hWndHooked, _listWindowsToSkip );
- _Surface( false );
- lResult = TRUE;
- }
- return true;
- case WM_MDITILE:
- {
- CList < HWND, HWND > _listWindowsToSkip;
- if( m_hWndSurface != NULL )
- _listWindowsToSkip.AddTail( m_hWndSurface );
- CExtNcFrameImpl::stat_MDI_Tile( hWndHooked, _listWindowsToSkip, wParam );
- _Surface( false );
- lResult = TRUE;
- }
- return true;
- case WM_MDICASCADE:
- {
- CList < HWND, HWND > _listWindowsToSkip;
- if( m_hWndSurface != NULL )
- _listWindowsToSkip.AddTail( m_hWndSurface );
- CExtNcFrameImpl::stat_MDI_Cascade( hWndHooked, _listWindowsToSkip, wParam );
- _Surface( false );
- lResult = TRUE;
- }
- return true;
- } // switch( nMessage )
- }
- break;
- default:
- if( nMessage == CExtNcFrameWatchMDIMF::g_nMsgSurface )
- {
- _Surface( wParam ? true : false );
- lResult = 1L;
- return true;
- }
- break;
- } // switch( nMessage )
- } // if( m_pNcFrameImpl != NULL )
- return
- CExtHookSink::OnHookWndMsg(
- lResult,
- hWndHooked,
- nMessage,
- wParam,
- lParam
- );
- }
- void CExtNcFrameWatchMDIMF::OnPostHookWndMsg(
- LRESULT lResult,
- HWND hWndHooked,
- UINT nMessage,
- WPARAM wParam,
- LPARAM lParam
- )
- {
- if( m_pNcFrameImpl != NULL )
- {
- switch( nMessage )
- {
- case WM_MDIDESTROY:
- case WM_MDINEXT:
- case WM_MDIICONARRANGE:
- case WM_MDITILE:
- case WM_MDICASCADE:
- case WM_MDIACTIVATE:
- //case WM_MDICREATE:
- {
- CRect rcMC;
- ::GetWindowRect( hWndHooked, &rcMC );
- ::SendMessage( hWndHooked, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rcMC.Width(),rcMC.Height()) );
- _Surface( false );
- ::RedrawWindow( hWndHooked, NULL, NULL,
- RDW_INVALIDATE|RDW_ERASE|RDW_FRAME|RDW_ALLCHILDREN
- );
- }
- break;
- } // switch( nMessage )
- } // if( m_pNcFrameImpl != NULL )
- CExtHookSink::OnPostHookWndMsg(
- lResult,
- hWndHooked,
- nMessage,
- wParam,
- lParam
- );
- }
- #endif // (!defined __EXT_MFC_NO_NC_FRAME )