From 716645d36139d6522822b7ae80e509e812c6c693 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Mar 2003 14:24:34 +0000 Subject: [PATCH] maximize the window to the correct display (i.e. the one it is currently on); ShowFullScreen() actually shows the window, too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/frame.tex | 10 +++-- src/msw/toplevel.cpp | 84 ++++++++++++++++++++++++++--------------- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/docs/latex/wx/frame.tex b/docs/latex/wx/frame.tex index 34823f2d60..e351ee10dc 100644 --- a/docs/latex/wx/frame.tex +++ b/docs/latex/wx/frame.tex @@ -612,9 +612,10 @@ Sets the frame title. \func{bool}{ShowFullScreen}{\param{bool}{ show}, \param{long}{ style = wxFULLSCREEN\_ALL}} -Passing true to {\it shows} shows the frame full-screen, and passing false restores the frame -again. {\it style} is a bit list containing some or all of the following values, which -indicate what elements of the frame to hide in full-screen mode: +Depending on the value of {\it show} parameter the frame is either shown full +screen or restored to its normal state. {\it style} is a bit list containing +some or all of the following values, which indicate what elements of the frame +to hide in full-screen mode: \begin{itemize}\itemsep=0pt \item wxFULLSCREEN\_NOMENUBAR @@ -627,6 +628,9 @@ indicate what elements of the frame to hide in full-screen mode: This function has not been tested with MDI frames. +Note that showing a frame full screen also actually +\helpref{Show()s}{wxwindowshow} if it hadn't been shown yet. + \wxheading{See also} \helpref{wxFrame::IsFullScreen}{wxframeisfullscreen} diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 4758fd9a52..96320bcfef 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -42,7 +42,7 @@ #include "wx/msw/private.h" -#include "wx/popupwin.h" +#include "wx/display.h" #ifndef ICON_BIG #define ICON_BIG 1 @@ -600,18 +600,22 @@ void wxTopLevelWindowMSW::Restore() bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) { - if (show) + if ( show == IsFullScreen() ) { - if (IsFullScreen()) - return FALSE; + // nothing to do + return TRUE; + } + + m_fsIsShowing = show; - m_fsIsShowing = TRUE; + if ( show ) + { m_fsStyle = style; // zap the frame borders // save the 'normal' window style - m_fsOldWindowStyle = GetWindowLong((HWND)GetHWND(), GWL_STYLE); + m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE); // save the old position, width & height, maximize state m_fsOldSize = GetRect(); @@ -624,44 +628,64 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) if (style & wxFULLSCREEN_NOBORDER) offFlags |= WS_BORDER | WS_THICKFRAME; if (style & wxFULLSCREEN_NOCAPTION) - offFlags |= (WS_CAPTION | WS_SYSMENU); + offFlags |= WS_CAPTION | WS_SYSMENU; - newStyle &= (~offFlags); + newStyle &= ~offFlags; // change our window style to be compatible with full-screen mode - ::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle); - - // resize to the size of the desktop - int width, height; + ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle); - RECT rect = wxGetWindowRect(::GetDesktopWindow()); - width = rect.right - rect.left; - height = rect.bottom - rect.top; + wxRect rect; +#if wxUSE_DISPLAY + // resize to the size of the display containing us + int dpy = wxDisplay::GetFromWindow(this); + if ( dpy != wxNOT_FOUND ) + { + rect = wxDisplay(dpy).GetGeometry(); + } + else // fall back to the main desktop +#else // wxUSE_DISPLAY + { + // resize to the size of the desktop + wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect); + } +#endif // wxUSE_DISPLAY - SetSize(width, height); + SetSize(rect); // now flush the window style cache and actually go full-screen - SetWindowPos((HWND)GetHWND(), HWND_TOP, 0, 0, width, height, SWP_FRAMECHANGED); + long flags = SWP_FRAMECHANGED; - wxSizeEvent event(wxSize(width, height), GetId()); - GetEventHandler()->ProcessEvent(event); + // showing the frame full screen should also show it if it's still + // hidden + if ( !IsShown() ) + { + // don't call wxWindow version to avoid flicker from calling + // ::ShowWindow() -- we're going to show the window at the correct + // location directly below -- but do call the wxWindowBase version + // to sync the internal m_isShown flag + wxWindowBase::Show(); - return TRUE; - } - else - { - if (!IsFullScreen()) - return FALSE; + flags |= SWP_SHOWWINDOW; + } - m_fsIsShowing = FALSE; + SetWindowPos(GetHwnd(), HWND_TOP, + rect.x, rect.y, rect.width, rect.height, + flags); + // finally send an event allowing the window to relayout itself &c + wxSizeEvent event(rect.GetSize(), GetId()); + GetEventHandler()->ProcessEvent(event); + } + else // stop showing full screen + { Maximize(m_fsIsMaximized); - SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle); - SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, + SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle); + SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED); - - return TRUE; } + + return TRUE; } // ---------------------------------------------------------------------------- -- 2.45.2