\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}.
\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
#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
#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
*/
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 )
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 )
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,
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();
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)
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
}
#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,
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__
wxLogLastError(wxT("MoveWindow"));
}
}
- else
+ else // creating a normal window, not a dialog
{
int controlId = 0;
if ( style & WS_CHILD )
}
wxWndHook = NULL;
+
#ifdef __WXDEBUG__
wxNode* node = wxWinHandleList->Member(this);
if (node)
wxLogError(wxT("A second HWND association is being added for the same window!"));
}
}
-#endif
+#endif // Debug
+
wxAssociateWinWithHandle((HWND) m_hWnd, this);
return TRUE;