Thank you for reporting this issue. The fix consists of two parts:
1) The CExtNcFrameImpl::NcFrameImpl_PreWindowProc()
method is organized into big switch
statement. Please update the following part of it:
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;
2) The
CExtNcFrameImpl::~CExtNcFrameImpl()
destructor:
CExtNcFrameImpl::~CExtNcFrameImpl()
{
m_wndNcFrameImpl_Tip.Hide();
if( m_wndNcFrameImpl_Tip.GetSafeHwnd() != NULL )
m_wndNcFrameImpl_Tip.DestroyWindow();
m_BridgeNC.NcFrameImpl_Set( NULL );
NcFrameImpl_MapHtRects_Clean();
}