changes to wxFRAME_NO_TASKBAR/FLOAT_ON_PARENT styles handling which should

now work more as expected


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15665 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-05-25 17:11:19 +00:00
parent 146ba0feac
commit 9dfef5ac20
7 changed files with 117 additions and 47 deletions

View File

@@ -88,8 +88,7 @@ wxMSW:
make/project files. make/project files.
- child frames appear in the taskbar by default now, use wxFRAME_NO_TASKBAR - child frames appear in the taskbar by default now, use wxFRAME_NO_TASKBAR
style to avoid it, wxFRAME_FLOAT_ON_PARENT style is now obsolete and has no style to avoid it
effect
- all overloads of wxDC::SetClippingRegion() combine the given region with the - all overloads of wxDC::SetClippingRegion() combine the given region with the
previously selected one instead of replacing it previously selected one instead of replacing it

View File

@@ -31,18 +31,21 @@ application windows.
\twocolitem{\windowstyle{wxMINIMIZE\_BOX}}{Displays a minimize box on the frame.} \twocolitem{\windowstyle{wxMINIMIZE\_BOX}}{Displays a minimize box on the frame.}
\twocolitem{\windowstyle{wxMAXIMIZE}}{Displays the frame maximized. Windows only.} \twocolitem{\windowstyle{wxMAXIMIZE}}{Displays the frame maximized. Windows only.}
\twocolitem{\windowstyle{wxMAXIMIZE\_BOX}}{Displays a maximize box on the frame.} \twocolitem{\windowstyle{wxMAXIMIZE\_BOX}}{Displays a maximize box on the frame.}
\twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{Stay on top of other windows. Windows only.} \twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{Stay on top of all other windows,
see also wxFRAME\_FLOAT\_ON\_PARENT. Windows only.}
\twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Displays a system menu.} \twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Displays a system menu.}
\twocolitem{\windowstyle{wxSIMPLE\_BORDER}}{Displays no border or decorations. GTK and Windows only.} \twocolitem{\windowstyle{wxSIMPLE\_BORDER}}{Displays no border or decorations. GTK and Windows only.}
\twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window.} \twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window.}
\twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}{Causes a frame with a small \twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}{Causes a frame with a small
titlebar to be created; the frame does not appear in the taskbar under Windows.} titlebar to be created; the frame does not appear in the taskbar under Windows.}
\twocolitem{\windowstyle{wxFRAME\_NO\_TASKBAR}}{Creates a normal frame but if \twocolitem{\windowstyle{wxFRAME\_NO\_TASKBAR}}{Creates an otherwise normal
this frame has a parent it does not appear in the taskbar under Windows. Note frame but it does not appear in the taskbar under Windows (note that it will
that a frame without parent will still appear in the taskbar even with this minimize to the desktop window which may seem strange to the users and thus it
style. Has no effect under other platforms.} might be better to use this style only without wxMINIMIZE\_BOX style).
\twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{Unused any longer, use Has no effect under other platforms.}
wxFRAME\_TOOL\_WINDOW or wxFRAME\_NO\_TASKBAR instead} \twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{The frame will always be
on top of its parent (unlike wxSTAY\_ON\_TOP). A frame created with this style
must have a non-NULL parent.}
\twocolitem{\windowstyle{wxFRAME\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the \twocolitem{\windowstyle{wxFRAME\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended

View File

@@ -946,11 +946,11 @@ enum wxBorder
#define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window #define wxDIALOG_NO_PARENT 0x0001 // Don't make owned by apps top window
#define wxFRAME_NO_TASKBAR 0x0002 // No taskbar button (MSW only) #define wxFRAME_NO_TASKBAR 0x0002 // No taskbar button (MSW only)
#define wxFRAME_TOOL_WINDOW 0x0004 // No taskbar button, no system menu #define wxFRAME_TOOL_WINDOW 0x0004 // No taskbar button, no system menu
#define wxFRAME_FLOAT_ON_PARENT 0x0008 // Always above its parent
// deprecated versions defined for compatibility reasons // deprecated versions defined for compatibility reasons
#define wxRESIZE_BOX wxMAXIMIZE_BOX #define wxRESIZE_BOX wxMAXIMIZE_BOX
#define wxTHICK_FRAME wxRESIZE_BORDER #define wxTHICK_FRAME wxRESIZE_BORDER
#define wxFRAME_FLOAT_ON_PARENT wxFRAME_TOOL_WINDOW
// obsolete styles, unused any more // obsolete styles, unused any more
#define wxDIALOG_MODAL 0x0020 // free flag value 0x0020 #define wxDIALOG_MODAL 0x0020 // free flag value 0x0020

View File

@@ -96,6 +96,9 @@ protected:
// translate wxWindows flags to Windows ones // translate wxWindows flags to Windows ones
virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const; virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const;
// choose the right parent to use with CreateWindow()
virtual WXHWND MSWGetParent() const;
// we handle WM_NCACTIVATE specially here // we handle WM_NCACTIVATE specially here
virtual long MSWWindowProc(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam); virtual long MSWWindowProc(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam);
@@ -112,6 +115,10 @@ protected:
long m_fsOldWindowStyle; long m_fsOldWindowStyle;
bool m_fsIsMaximized; bool m_fsIsMaximized;
bool m_fsIsShowing; bool m_fsIsShowing;
// the hidden parent window for the frames which shouldn't appear in the
// taskbar
static wxWindow *ms_hiddenParent;
}; };
// list of all frames and modeless dialogs // list of all frames and modeless dialogs

View File

@@ -240,6 +240,9 @@ public:
int& x, int& y, int& x, int& y,
int& w, int& h) const; int& w, int& h) const;
// get the HWND to be used as parent of this window with CreateWindow()
virtual WXHWND MSWGetParent() const;
// creates the window of specified Windows class with given style, extended // creates the window of specified Windows class with given style, extended
// style, title and geometry (default values // style, title and geometry (default values
// //

View File

@@ -70,6 +70,9 @@ wxWindowList wxModelessWindows;
// the name of the default wxWindows class // the name of the default wxWindows class
extern const wxChar *wxCanvasClassName; extern const wxChar *wxCanvasClassName;
// the hidden parent for wxFRAME_NO_TASKBAR unowned frames
wxWindow *wxTopLevelWindowMSW::ms_hiddenParent = NULL;
// ============================================================================ // ============================================================================
// wxTopLevelWindowMSW implementation // wxTopLevelWindowMSW implementation
// ============================================================================ // ============================================================================
@@ -175,14 +178,30 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
#if !defined(__WIN16__) && !defined(__SC__) #if !defined(__WIN16__) && !defined(__SC__)
if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ) if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) )
{ {
// make all frames appear in the win9x shell taskbar unless if ( style & wxFRAME_TOOL_WINDOW )
// wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without {
// giving them WS_EX_APPWINDOW style, the child (i.e. owned) frames // create the palette-like window
// wouldn't appear in it
if ( (style & wxFRAME_TOOL_WINDOW) || (style & wxFRAME_NO_TASKBAR) )
*exflags |= WS_EX_TOOLWINDOW; *exflags |= WS_EX_TOOLWINDOW;
else if ( !(style & wxFRAME_NO_TASKBAR) ) }
// We have to solve 2 different problems here:
//
// 1. frames with wxFRAME_NO_TASKBAR flag shouldn't appear in the
// taskbar even if they don't have a parent
//
// 2. frames without this style should appear in the taskbar even
// if they're owned (Windows only puts non owned windows into
// the taskbar normally)
//
// The second one is solved here by using WS_EX_APPWINDOW flag, the
// first one is dealt with in our MSWGetParent() method
// implementation
if ( !(style & wxFRAME_NO_TASKBAR) && GetParent() )
{
// need to force the frame to appear in the taskbar
*exflags |= WS_EX_APPWINDOW; *exflags |= WS_EX_APPWINDOW;
}
//else: nothing to do [here]
} }
#endif // !Win16 #endif // !Win16
@@ -198,6 +217,46 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
return msflags; return msflags;
} }
WXHWND wxTopLevelWindowMSW::MSWGetParent() const
{
// for the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL
// parent HWND or it would be always on top of its parent which is not what
// we usually want (in fact, we only want it for frames with the
// wxFRAME_FLOAT_ON_PARENT flag)
wxWindow *parent;
if ( HasFlag(wxFRAME_FLOAT_ON_PARENT) )
{
parent = GetParent();
// this flag doesn't make sense then and will be ignored
wxASSERT_MSG( parent,
_T("wxFRAME_FLOAT_ON_PARENT but no parent?") );
}
else // don't float on parent, must not be owned
{
parent = NULL;
}
// now deal with the 2nd taskbar-related problem (see comments above in
// MSWGetStyle())
if ( HasFlag(wxFRAME_NO_TASKBAR) && !parent )
{
if ( !ms_hiddenParent )
{
ms_hiddenParent = new wxTopLevelWindowMSW(NULL, -1, _T(""));
// we shouldn't leave it in wxTopLevelWindows or we wouldn't
// terminate the app when the last user-created frame is deleted --
// see ~wxTopLevelWindowMSW
wxTopLevelWindows.DeleteObject(ms_hiddenParent);
}
parent = ms_hiddenParent;
}
return parent ? parent->GetHWND() : NULL;
}
bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
@@ -402,6 +461,13 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent,
wxTopLevelWindowMSW::~wxTopLevelWindowMSW() wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
{ {
if ( this == ms_hiddenParent )
{
// stop [infinite] recursion which would otherwise happen when we do
// "delete ms_hiddenParent" below
return;
}
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if ( wxModelessWindows.Find(this) ) if ( wxModelessWindows.Find(this) )
@@ -410,6 +476,12 @@ wxTopLevelWindowMSW::~wxTopLevelWindowMSW()
// If this is the last top-level window, exit. // If this is the last top-level window, exit.
if ( wxTheApp && (wxTopLevelWindows.Number() == 0) ) if ( wxTheApp && (wxTopLevelWindows.Number() == 0) )
{ {
if ( ms_hiddenParent )
{
delete ms_hiddenParent;
ms_hiddenParent = NULL;
}
wxTheApp->SetTopWindow(NULL); wxTheApp->SetTopWindow(NULL);
if ( wxTheApp->GetExitOnFrameDelete() ) if ( wxTheApp->GetExitOnFrameDelete() )

View File

@@ -2903,6 +2903,11 @@ bool wxWindowMSW::MSWGetCreateWindowCoords(const wxPoint& pos,
return nonDefault; return nonDefault;
} }
WXHWND wxWindowMSW::MSWGetParent() const
{
return m_parent ? m_parent->GetHWND() : NULL;
}
bool wxWindowMSW::MSWCreate(const wxChar *wclass, bool wxWindowMSW::MSWCreate(const wxChar *wclass,
const wxChar *title, const wxChar *title,
const wxPoint& pos, const wxPoint& pos,
@@ -2914,29 +2919,10 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
int x, y, w, h; int x, y, w, h;
(void)MSWGetCreateWindowCoords(pos, size, x, y, w, h); (void)MSWGetCreateWindowCoords(pos, size, x, y, w, h);
// find the correct parent HWND
wxWindow *parent = GetParent();
bool isChild = (style & WS_CHILD) != 0;
HWND hParent;
if ( (isChild || HasFlag(wxPOPUP_WINDOW) || HasFlag(wxFRAME_TOOL_WINDOW)) )
{
// this is either a normal child window, a popup window or a top level
// window with wxFRAME_TOOL_WINDOW style (see below)
hParent = parent ? GetHwndOf(parent) : NULL;
}
else
{
// this is a frame without wxFRAME_TOOL_WINDOW style: we should use
// NULL parent HWND for it or it would be always on top of its parent
// which is not what we usually want (in fact, we only want it for
// frames with the special wxFRAME_TOOL_WINDOW as above)
hParent = NULL;
}
// controlId is menu handle for the top level windows, so set it to 0 // controlId is menu handle for the top level windows, so set it to 0
// unless we're creating a child window // unless we're creating a child window
int controlId; int controlId;
if ( isChild ) if ( style & WS_CHILD )
{ {
controlId = GetId(); controlId = GetId();
@@ -2963,17 +2949,17 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass,
wxWindowCreationHook hook(this); wxWindowCreationHook hook(this);
m_hWnd = (WXHWND)::CreateWindowEx m_hWnd = (WXHWND)::CreateWindowEx
( (
extendedStyle, extendedStyle,
className, className,
title ? title : wxT(""), title ? title : wxT(""),
style, style,
x, y, w, h, x, y, w, h,
hParent, (HWND)MSWGetParent(),
(HMENU)controlId, (HMENU)controlId,
wxGetInstance(), wxGetInstance(),
NULL // no extra data NULL // no extra data
); );
if ( !m_hWnd ) if ( !m_hWnd )
{ {