From bf505d2855898509f6a14aa0036c28ef72c0d79c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 May 2001 01:09:21 +0000 Subject: [PATCH] correct fix for Maximize() for hidden frames git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10042 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/frame.h | 10 ++++++++-- src/msw/frame.cpp | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/include/wx/msw/frame.h b/include/wx/msw/frame.h index d9c67c2bd2..5e161cd3ab 100644 --- a/include/wx/msw/frame.h +++ b/include/wx/msw/frame.h @@ -145,10 +145,16 @@ protected: // window proc for the frames long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); - + virtual bool IsMDIChild() const { return FALSE; } - bool m_iconized; + // is the frame currently iconized? + bool m_iconized; + + // should the frame be maximized when it will be shown? set by Maximize() + // when it is called while the frame is hidden + bool m_maximizeOnShow; + WXHICON m_defaultIcon; #if wxUSE_STATUSBAR diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 6723824373..9a699cfebc 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -95,7 +95,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) void wxFrame::Init() { - m_iconized = FALSE; + m_iconized = + m_maximizeOnShow = FALSE; #if wxUSE_TOOLTIPS m_hwndToolTip = 0; @@ -293,7 +294,27 @@ bool wxFrame::Show(bool show) if ( !wxWindowBase::Show(show) ) return FALSE; - DoShowWindow(show ? SW_SHOW : SW_HIDE); + int nShowCmd; + if ( show ) + { + if ( m_maximizeOnShow ) + { + // show and maximize + nShowCmd = SW_MAXIMIZE; + + m_maximizeOnShow = FALSE; + } + else // just show + { + nShowCmd = SW_SHOW; + } + } + else // hide + { + nShowCmd = SW_HIDE; + } + + DoShowWindow(nShowCmd); if ( show ) { @@ -303,7 +324,7 @@ bool wxFrame::Show(bool show) event.SetEventObject( this ); GetEventHandler()->ProcessEvent(event); } - else + else // hide { // Try to highlight the correct window (the parent) if ( GetParent() ) @@ -324,7 +345,17 @@ void wxFrame::Iconize(bool iconize) void wxFrame::Maximize(bool maximize) { - DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE); + if ( IsShown() ) + { + // just maximize it directly + DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE); + } + else // hidden + { + // we can't maximize the hidden frame because it shows it as well, so + // just remember that we should do it later in this case + m_maximizeOnShow = TRUE; + } } void wxFrame::Restore() -- 2.45.2