From: Vadim Zeitlin Date: Wed, 11 Oct 2000 13:16:37 +0000 (+0000) Subject: added (MSW/GTK) and documented new frame and dialog flags X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b3daa5a32277ef8f31390f7a178ea14735b3f069?ds=sidebyside added (MSW/GTK) and documented new frame and dialog flags git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8523 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/dialog.tex b/docs/latex/wx/dialog.tex index fd7d6df18a..7cb3303523 100644 --- a/docs/latex/wx/dialog.tex +++ b/docs/latex/wx/dialog.tex @@ -43,14 +43,20 @@ dialog to respond to system close events. \twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{The dialog stays on top of all other windows (Windows only).} \twocolitem{\windowstyle{wxNO\_3D}}{Under Windows, specifies that the child controls should not have 3D borders unless specified in the control.} +\twocolitem{\windowstyle{wxDIALOG\_NO\_PARENT}}{By default, the dialogs crated +with {\tt NULL} parent window will be given the +\helpref{applications top level window}{wxappgettopwindow} as parent. Use this +style to prevent this from happening and create a really orphan dialog (note +that this is not recommended for modal dialogs).} \twocolitem{\windowstyle{wxDIALOG\_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 a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended style and must be set by calling \helpref{SetExtraStyle}{wxwindowsetextrastyle} before Create is called (two-step construction).} \end{twocollist} -Under Unix or Linux, MWM (the Motif Window Manager) or other window managers reckognizing -the MHM hints should be running for any of these styles to have an effect. +Under Unix or Linux, MWM (the Motif Window Manager) or other window managers +reckognizing the MHM hints should be running for any of these styles to have an +effect. See also \helpref{Generic window styles}{windowstyles}. diff --git a/docs/latex/wx/frame.tex b/docs/latex/wx/frame.tex index edff41d704..0bc42220db 100644 --- a/docs/latex/wx/frame.tex +++ b/docs/latex/wx/frame.tex @@ -34,12 +34,15 @@ application windows. \twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{Stay on top of other windows. Windows only.} \twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Displays a system menu.} \twocolitem{\windowstyle{wxSIMPLE\_BORDER}}{Displays no border or decorations. GTK and Windows only.} -\twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window (Unix only).} -\twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{Causes the frame to be above the parent window in the -z-order and not shown in the taskbar. Without this style, frames are created as top-level windows that may be obscured by -the parent window, and frame titles are shown in the taskbar. Windows and GTK.} -\twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}{Causes a frame with a small titlebar to be created; -the frame title does not appear in the taskbar. Windows only.} +\twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window.} +\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.} +\twocolitem{\windowstyle{wxFRAME\_NO\_TASKBAR}}{Creates a normal frame but if +this frame has a parent it does not appear in the taskbar under Windows. Note +that a frame without parent will still appear in the taskbar even with this +style. Has no effect under other platforms.} +\twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{Unused any longer, use +wxFRAME\_TOOL\_WINDOW or wxFRAME\_NO\_TASKBAR instead} \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 a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended diff --git a/include/wx/defs.h b/include/wx/defs.h index c85c805dd1..e8fc516dc6 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -912,10 +912,15 @@ enum wxStretch #define wxTINY_CAPTION_VERT 0x0080 #define wxRESIZE_BORDER 0x0040 +#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_TOOL_WINDOW 0x0004 // No taskbar button, no system menu + // deprecated versions defined for compatibility reasons #define wxRESIZE_BOX wxMAXIMIZE_BOX #define wxTHICK_FRAME wxRESIZE_BORDER +// obsolete styles, unused any more #define wxDIALOG_MODAL 0x0020 #define wxDIALOG_MODELESS 0x0000 @@ -1156,12 +1161,6 @@ enum wxStretch #define wxSP_FULLSASH 0x0400 #define wxSP_3D (wxSP_3DBORDER | wxSP_3DSASH) -/* - * wxFrame extra flags - */ -// No title on taskbar -#define wxFRAME_TOOL_WINDOW 0x0004 - /* * wxTabCtrl flags */ diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index b52338cef1..a4532f5d19 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -632,7 +632,9 @@ int wxDialog::ShowModal() return GetReturnCode(); } - if ( !GetParent() ) + // use the apps top level window as parent if none given unless explicitly + // forbidden + if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) { wxWindow *parent = wxTheApp->GetTopWindow(); if ( parent && parent != this ) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index b52338cef1..a4532f5d19 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -632,7 +632,9 @@ int wxDialog::ShowModal() return GetReturnCode(); } - if ( !GetParent() ) + // use the apps top level window as parent if none given unless explicitly + // forbidden + if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) { wxWindow *parent = wxTheApp->GetTopWindow(); if ( parent && parent != this ) diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 1b2d7c48a5..889355a4b8 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -107,7 +107,8 @@ void wxDialog::Init() SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); } -bool wxDialog::Create(wxWindow *parent, wxWindowID id, +bool wxDialog::Create(wxWindow *parent, + wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, @@ -122,9 +123,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, wxTopLevelWindows.Append(this); - // windowFont = wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL); - - if (parent) parent->AddChild(this); + if ( parent ) + parent->AddChild(this); if ( id == -1 ) m_windowId = (int)NewControlId(); @@ -159,6 +159,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, if (m_exStyle & wxDIALOG_EX_CONTEXTHELP) extendedStyle |= WS_EX_CONTEXTHELP; #endif + // Allows creation of dialogs with & without captions under MSWindows, // resizeable or not (but a resizeable dialog always has caption - // otherwise it would look too strange) diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index be0e9d10e2..501b0fe8b6 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -666,12 +666,12 @@ bool wxFrame::MSWCreate(int id, wxWindow *parent, const wxChar *wclass, wxWindow WXDWORD extendedStyle = MakeExtendedStyle(style); // make all frames appear in the win9x shell taskbar unless - // wxFRAME_TOOL_WINDOW is explicitly given - without giving them + // wxFRAME_TOOL_WINDOW or wxFRAME_NO_TASKBAR is given - without giving them // WS_EX_APPWINDOW style, the child (i.e. owned) frames wouldn't appear in it #if !defined(__WIN16__) && !defined(__SC__) - if (style & wxFRAME_TOOL_WINDOW) + if ( style & wxFRAME_TOOL_WINDOW ) extendedStyle |= WS_EX_TOOLWINDOW; - else + else if ( !(style & wxFRAME_NO_TASKBAR) ) extendedStyle |= WS_EX_APPWINDOW; #endif diff --git a/src/msw/window.cpp b/src/msw/window.cpp index e6d0d10345..b19210ce93 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2366,14 +2366,22 @@ bool wxWindow::MSWCreate(int id, } #endif // 0 - HWND hParent = (HWND)NULL; - if ( parent ) - hParent = (HWND) parent->GetHWND(); + HWND hParent = parent ? GetHwndOf(parent) : NULL; wxWndHook = this; if ( dialog_template ) { + // for the dialogs without wxDIALOG_NO_PARENT style, use the top level + // app window as parent - this avoids creating modal dialogs without + // parent + if ( !hParent && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) + { + wxWindow *winTop = wxTheApp->GetTopWindow(); + if ( winTop ) + hParent = GetHwndOf(winTop); + } + m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(), dialog_template, hParent, @@ -2381,27 +2389,37 @@ bool wxWindow::MSWCreate(int id, if ( m_hWnd == 0 ) { - wxLogError(_("Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.")); + wxLogError(_("Can't find dialog template '%s'!\nCheck resource include path for finding wx.rc."), + dialog_template); return FALSE; } - if (extendedStyle != 0) + + if ( extendedStyle != 0 ) { ::SetWindowLong(GetHwnd(), GWL_EXSTYLE, extendedStyle); ::SetWindowPos(GetHwnd(), NULL, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + SWP_NOSIZE | + SWP_NOMOVE | + SWP_NOZORDER | + SWP_NOACTIVATE); } + #if defined(__WIN95__) // For some reason, the system menu is activated when we use the // WS_EX_CONTEXTHELP style, so let's set a reasonable icon if (extendedStyle & WS_EX_CONTEXTHELP) { - if (wxTheApp->GetTopWindow() && (wxTheApp->GetTopWindow()->IsKindOf(CLASSINFO(wxFrame)))) + wxFrame *winTop = wxDynamicCast(wxTheApp->GetTopWindow(), wxFrame); + if ( winTop ) { - wxIcon icon = ((wxFrame*)wxTheApp->GetTopWindow())->GetIcon(); - if (icon.Ok()) - SendMessage(GetHwnd(), WM_SETICON, - (WPARAM)TRUE, (LPARAM)(HICON) icon.GetHICON()); + wxIcon icon = winTop->GetIcon(); + if ( icon.Ok() ) + { + ::SendMessage(GetHwnd(), WM_SETICON, + (WPARAM)TRUE, + (LPARAM)GetHiconOf(icon)); + } } } #endif // __WIN95__ @@ -2426,7 +2444,7 @@ bool wxWindow::MSWCreate(int id, wxLogLastError(wxT("MoveWindow")); } } - else + else // creating a normal window, not a dialog { int controlId = 0; if ( style & WS_CHILD ) @@ -2462,6 +2480,7 @@ bool wxWindow::MSWCreate(int id, } wxWndHook = NULL; + #ifdef __WXDEBUG__ wxNode* node = wxWinHandleList->Member(this); if (node) @@ -2472,7 +2491,8 @@ bool wxWindow::MSWCreate(int id, wxLogError(wxT("A second HWND association is being added for the same window!")); } } -#endif +#endif // Debug + wxAssociateWinWithHandle((HWND) m_hWnd, this); return TRUE;