Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » BUG: too large window after theme switch Collapse All
Subject Author Date
Ulrich Heinicke May 31, 2010 - 11:04 PM




Hi, i’m using the version 2.89 under XP SP3. My program starts with the theme CExtPaintManagerXP in maximized mode. It’s work ok.




After switching to an Office 2007 or Office 2010 theme the window is too large.



In every corner there are pixels missing.

Technical Support Jun 2, 2010 - 10:35 AM

Thank you for reporting this issue. To fix it, please update the source code for the following method:

void CExtPmBridgeNC::_AdjustThemeSettings()
{
            if(                     m_pNcFrameImpl == NULL
                        ||           m_pNcFrameImpl->m_bNcFrameImpl_InAdjustAdjustThemeSettings
                        )
                        return;
            m_pNcFrameImpl->m_bNcFrameImpl_CreatePassed = true;
HWND hWndOwn = PmBridge_GetSafeHwnd();
            if( hWndOwn == NULL )
                        return;
            ASSERT( ::IsWindow( hWndOwn ) );
            m_pNcFrameImpl->m_bNcFrameImpl_InAdjustAdjustThemeSettings = true;
WINDOWPLACEMENT _wp;
            ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
            _wp.length = sizeof(WINDOWPLACEMENT);
            CExtNcFrameImpl::stat_GetWindowPlacement( hWndOwn, _wp );
            if( ( ::__EXT_MFC_GetWindowLong( hWndOwn, GWL_STYLE ) & WS_VISIBLE ) == 0 )
                        _wp.showCmd = SW_HIDE;
CWnd * pWndFrameImpl = (CWnd *)m_pNcFrameImpl->NcFrameImpl_GetFrameWindow();
            pWndFrameImpl->ModifyStyle( 0, WS_CAPTION|WS_BORDER, 0 );
            m_pNcFrameImpl->m_bNcFrameImpl_IsActive = false;
            if( pWndFrameImpl != NULL && pWndFrameImpl->IsWindowEnabled() )
            {
                        HWND hWndFocus = ::GetFocus();
                        if(                     hWndFocus != NULL
                                    &&        (           pWndFrameImpl->m_hWnd == hWndFocus
                                    ||           ::IsChild( pWndFrameImpl->m_hWnd, hWndFocus )
                                                )
                                    )
                                    m_pNcFrameImpl->m_bNcFrameImpl_IsActive = true;
            }
DWORD dwInitialStyle = m_pNcFrameImpl->NcFrameImpl_GetInitialStyle();
DWORD dwCurrentStyle = dwInitialStyle;
HWND hWndSurface = NULL;
            if(                     (dwCurrentStyle&(WS_CHILD|WS_VISIBLE)) == WS_VISIBLE
                        &&        (! m_pNcFrameImpl->m_bNcFrameImpl_PivotPmSyncMode )
                        )
            {
                        CRect rcSurface;
                        ::GetWindowRect( hWndOwn, &rcSurface );
                        hWndSurface =
                                    ::CreateWindowEx(
                                                0, _T("Static"), _T(""), WS_POPUP,
                                                rcSurface.left,
                                                rcSurface.top,
                                                rcSurface.Width() + ( ( _wp.showCmd == SW_SHOWNORMAL && g_PaintManager.m_bIsWinXPorLater ) ? 1 : 0 ),
                                                rcSurface.Height(),
                                                hWndOwn, (HMENU)NULL, ::AfxGetInstanceHandle(), NULL
                                                );
                        if( hWndSurface != NULL )
                        {
                                    ::EnableWindow( hWndSurface, FALSE );
                                    ::ShowWindow( hWndSurface, SW_SHOWNOACTIVATE );
                        }
            }
CExtNcFrameImpl::NcLock _NcLock( * m_pNcFrameImpl );
            ::SetWindowRgn( hWndOwn, NULL, TRUE );
            if( ! ::IsWindow( hWndOwn ) )
                        return;
            _NcLock.UnlockNow();
            if( m_pNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement() )
                        m_pNcFrameImpl->NcFrameImpl_AdjustVistaDwmCompatibilityIssues();
            else
                        m_pNcFrameImpl->NcFrameImpl_SetupRgn();
            if(                     pWndFrameImpl != NULL
                        &&        pWndFrameImpl->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) )
                        &&        g_PaintManager.m_UxTheme.IsAppThemed()
                        )
            {
                        CRect rc;
                        pWndFrameImpl->GetWindowRect( &rc );
                        pWndFrameImpl->GetParent()->ScreenToClient( &rc );
                        rc.left ++;
                        pWndFrameImpl->MoveWindow( &rc, FALSE );
                        rc.left --;
                        pWndFrameImpl->MoveWindow( &rc, FALSE );
            }
            m_pNcFrameImpl->NcFrameImpl_RecalcNcFrame();
CWnd * pWndPermanent = CWnd::FromHandlePermanent( hWndOwn );
            if( pWndPermanent != NULL )
            {
                        CFrameWnd * pFrameWnd = DYNAMIC_DOWNCAST( CFrameWnd, pWndPermanent );
                        if( pFrameWnd != NULL )
                                    pFrameWnd->RecalcLayout();
            }
            if(                     m_pNcFrameImpl->NcFrameImpl_IsSupported()
                        &&        ( ! m_pNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement() )
                        )
            {
                        m_pNcFrameImpl->NcFrameImpl_SetupRgn( NULL );
                        ::RedrawWindow( hWndOwn, NULL, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME|RDW_ALLCHILDREN );
            }
            else
            {
                        m_pNcFrameImpl->NcFrameImpl_RecalcNcFrame();
                        if( (dwCurrentStyle&(WS_CHILD|WS_VISIBLE)) == WS_VISIBLE )
                        {
                                    switch( _wp.showCmd )
                                    {
                                    case SW_SHOWNORMAL:
                                                if( g_PaintManager.m_bIsWinXPorLater )
                                                {
                                                            CRect rc = _wp.rcNormalPosition;
                                                            rc.right++;
                                                            MoveWindow( hWndOwn, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE );
                                                            rc.right--;
                                                            MoveWindow( hWndOwn, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE );
                                                }
                                    break;
                                    }
                        }
            }
            if( m_pNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement() )
                        m_pNcFrameImpl->NcFrameImpl_RecalcNcFrame();
            else if( m_pNcFrameImpl->NcFrameImpl_IsSupported() )
                        CExtNcFrameImpl::stat_SetWindowPlacement( hWndOwn, _wp );
bool bContinueRecalc = true;
            while( bContinueRecalc )
            {
                        bContinueRecalc = false;
                        MSG _msg;
                        while( ::PeekMessage( &_msg, NULL, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, PM_NOREMOVE ) )
                        {
                                    if( ! ::GetMessage( &_msg, NULL, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED ) )
                                                break;
                                    ::DispatchMessage( &_msg );
                                    bContinueRecalc = true;
                        }
                        while( ::PeekMessage( &_msg, NULL, WM_NCCALCSIZE, WM_NCCALCSIZE, PM_NOREMOVE ) )
                        {
                                    if( ! ::GetMessage( &_msg, NULL, WM_NCCALCSIZE, WM_NCCALCSIZE ) )
                                                break;
                                    ::DispatchMessage( &_msg );
                                    bContinueRecalc = true;
                        }
                        while( ::PeekMessage( &_msg, NULL, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED, PM_NOREMOVE ) )
                        {
                                    if( ! ::GetMessage( &_msg, NULL, WM_WINDOWPOSCHANGING, WM_WINDOWPOSCHANGED ) )
                                                break;
                                    ::DispatchMessage( &_msg );
                                    bContinueRecalc = true;
                        }
                        while( ::PeekMessage( &_msg, NULL, WM_SIZE, WM_SIZE, PM_NOREMOVE ) )
                        {
                                    if( ! ::GetMessage( &_msg, NULL, WM_SIZE, WM_SIZE ) )
                                                break;
                                    ::DispatchMessage( &_msg );
                                    bContinueRecalc = true;
                        }
            }
            if( hWndSurface != NULL )
            {
                        ::DestroyWindow( hWndSurface );
                        CExtPaintManager::stat_PassPaintMessages();
            }
            if( ! m_pNcFrameImpl->NcFrameImpl_IsDwmBased() )
            {
                        HWND hWndCheckZoomState = m_pNcFrameImpl->NcFrameImpl_OnQueryHWND();
                        if(                     hWndCheckZoomState != NULL
                                    &&        ::IsWindow( hWndCheckZoomState )
                                    &&        ::IsZoomed( hWndCheckZoomState )
                                    )
                        {
                                    CExtPaintManager::monitor_parms_t _mp;
                                    CExtPaintManager::stat_GetMonitorParms( _mp, hWndCheckZoomState );
                                    ::SendMessage( hWndCheckZoomState, WM_SETREDRAW, 0L, 0L );
                                    MINMAXINFO _mmi;
                                    ::memset( &_mmi, 0, sizeof(MINMAXINFO) );
                                    _mmi.ptMaxPosition.x = _mp.m_rcWorkArea.left;
                                    _mmi.ptMaxPosition.y = _mp.m_rcWorkArea.top;
                                    _mmi.ptMaxTrackSize.x = _mp.m_rcWorkArea.Width();
                                    _mmi.ptMaxTrackSize.y = _mp.m_rcWorkArea.Height();
                                    _mmi.ptMinTrackSize.x = ::GetSystemMetrics( SM_CXMINTRACK );
                                    _mmi.ptMinTrackSize.y = ::GetSystemMetrics( SM_CYMINTRACK );
                                    _mmi.ptMaxSize.x = _mmi.ptMaxTrackSize.x;
                                    _mmi.ptMaxSize.y = _mmi.ptMaxTrackSize.y;
                                    ::SendMessage( hWndCheckZoomState, WM_GETMINMAXINFO, 0, LPARAM(&_mmi) );
                                    CSize maxSize(
                                                max( _mmi.ptMaxTrackSize.x, _mp.m_rcWorkArea.Width() ),
                                                max( _mmi.ptMaxTrackSize.y, _mp.m_rcWorkArea.Height() )
                                                );
                                    CRect rcMax( _mmi.ptMaxPosition, maxSize );
                                    WINDOWPLACEMENT _wp, _wp2;
                                    ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
                                    _wp.length = sizeof(WINDOWPLACEMENT);
                                    ::GetWindowPlacement( hWndCheckZoomState, &_wp );
                                    ::memcpy( &_wp2, &_wp, sizeof(WINDOWPLACEMENT) );
                                    CRect rcMaxInflated( rcMax );
                                    if( m_pNcFrameImpl->NcFrameImpl_IsSupported() )
                                    {
                                                CRect rcInflate, rcTmp;
                                                PmBridge_GetPM()->NcFrame_GetMetrics( rcInflate, rcTmp, pWndFrameImpl );
                                                rcMaxInflated.InflateRect( rcInflate );
                                    }
                                    else
                                                rcMaxInflated.InflateRect( ::GetSystemMetrics(SM_CXFRAME), ::GetSystemMetrics(SM_CYFRAME) );
                                    _wp2.ptMaxPosition = rcMaxInflated.TopLeft();
                                    ::CopyRect( &_wp2.rcNormalPosition, &rcMaxInflated );
                                    _wp2.showCmd = SW_SHOWMAXIMIZED;
                                    ::SetWindowPlacement( hWndCheckZoomState, &_wp2 );
                                    _wp.showCmd = SW_SHOWMAXIMIZED;
                                    ::SendMessage( hWndCheckZoomState, WM_SETREDRAW, 1L, 0L );
                                    ::SetWindowPlacement( hWndCheckZoomState, &_wp );
                        }
            }
            m_pNcFrameImpl->m_bNcFrameImpl_InAdjustAdjustThemeSettings = false;
}