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
This commit is contained in:
Vadim Zeitlin
2003-03-02 14:24:34 +00:00
parent 4a95c88547
commit 716645d361
2 changed files with 61 additions and 33 deletions

View File

@@ -612,9 +612,10 @@ Sets the frame title.
\func{bool}{ShowFullScreen}{\param{bool}{ show}, \param{long}{ style = wxFULLSCREEN\_ALL}} \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 Depending on the value of {\it show} parameter the frame is either shown full
again. {\it style} is a bit list containing some or all of the following values, which screen or restored to its normal state. {\it style} is a bit list containing
indicate what elements of the frame to hide in full-screen mode: some or all of the following values, which indicate what elements of the frame
to hide in full-screen mode:
\begin{itemize}\itemsep=0pt \begin{itemize}\itemsep=0pt
\item wxFULLSCREEN\_NOMENUBAR \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. 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} \wxheading{See also}
\helpref{wxFrame::IsFullScreen}{wxframeisfullscreen} \helpref{wxFrame::IsFullScreen}{wxframeisfullscreen}

View File

@@ -42,7 +42,7 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include "wx/popupwin.h" #include "wx/display.h"
#ifndef ICON_BIG #ifndef ICON_BIG
#define ICON_BIG 1 #define ICON_BIG 1
@@ -600,18 +600,22 @@ void wxTopLevelWindowMSW::Restore()
bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
{ {
if (show) if ( show == IsFullScreen() )
{ {
if (IsFullScreen()) // nothing to do
return FALSE; return TRUE;
}
m_fsIsShowing = TRUE; m_fsIsShowing = show;
if ( show )
{
m_fsStyle = style; m_fsStyle = style;
// zap the frame borders // zap the frame borders
// save the 'normal' window style // 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 // save the old position, width & height, maximize state
m_fsOldSize = GetRect(); m_fsOldSize = GetRect();
@@ -624,44 +628,64 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
if (style & wxFULLSCREEN_NOBORDER) if (style & wxFULLSCREEN_NOBORDER)
offFlags |= WS_BORDER | WS_THICKFRAME; offFlags |= WS_BORDER | WS_THICKFRAME;
if (style & wxFULLSCREEN_NOCAPTION) 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 // change our window style to be compatible with full-screen mode
::SetWindowLong((HWND)GetHWND(), GWL_STYLE, newStyle); ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);
// resize to the size of the desktop wxRect rect;
int width, height; #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
RECT rect = wxGetWindowRect(::GetDesktopWindow()); SetSize(rect);
width = rect.right - rect.left;
height = rect.bottom - rect.top;
SetSize(width, height);
// now flush the window style cache and actually go full-screen // 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()); // 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();
flags |= SWP_SHOWWINDOW;
}
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); GetEventHandler()->ProcessEvent(event);
return TRUE;
} }
else else // stop showing full screen
{ {
if (!IsFullScreen())
return FALSE;
m_fsIsShowing = FALSE;
Maximize(m_fsIsMaximized); Maximize(m_fsIsMaximized);
SetWindowLong((HWND)GetHWND(),GWL_STYLE, m_fsOldWindowStyle); SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
SetWindowPos((HWND)GetHWND(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y, SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED); m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
return TRUE;
} }
return TRUE;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------