m_fsIsShowing = FALSE;
}
-long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const
+WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const
{
- long style = GetWindowStyle();
+ // let the base class deal with the common styles but fix the ones which
+ // don't make sense for us (we also deal with the borders ourselves)
+ WXDWORD msflags = wxWindow::MSWGetStyle
+ (
+ (style & ~wxBORDER_MASK) | wxBORDER_NONE, exflags
+ ) & ~WS_CHILD;
// first select the kind of window being created
- long msflags;
+ //
+ // note that if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and
+ // creates a window with both caption and border, hence we also test it
+ // below in some other cases
if ( style & wxFRAME_TOOL_WINDOW )
- msflags = WS_POPUP;
+ msflags |= WS_POPUP;
else
- msflags = WS_OVERLAPPED;
+ msflags |= WS_OVERLAPPED;
// border and caption styles
if ( style & wxRESIZE_BORDER )
msflags |= WS_THICKFRAME;
else if ( !(style & wxBORDER_NONE) )
msflags |= WS_BORDER;
+ else
+ msflags |= WS_POPUP;
if ( style & wxCAPTION )
msflags |= WS_CAPTION;
-
- // if we don't set WS_POPUP, Windows assumes WS_OVERLAPPED and creates a
- // window with both caption and border
- if ( msflags & (WS_CAPTION | WS_BORDER) != WS_CAPTION | WS_BORDER )
- {
+ else
msflags |= WS_POPUP;
- }
// next translate the individual flags
if ( style & wxMINIMIZE_BOX )
if ( style & wxMAXIMIZE )
msflags |= WS_MAXIMIZE;
- if ( style & wxCLIP_CHILDREN )
- msflags |= WS_CLIPCHILDREN;
-
// Keep this here because it saves recoding this function in wxTinyFrame
#if wxUSE_ITSY_BITSY && !defined(__WIN32__)
if ( style & wxTINY_CAPTION_VERT )
if ( exflags )
{
- *exflags = MakeExtendedStyle(style);
-
#if !defined(__WIN16__) && !defined(__SC__)
if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) )
{
*exflags |= WS_EX_TOPMOST;
#ifdef __WIN32__
- if ( m_exStyle & wxFRAME_EX_CONTEXTHELP )
+ if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP )
*exflags |= WS_EX_CONTEXTHELP;
#endif // __WIN32__
}
return msflags;
}
-bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate,
+bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate,
const wxString& title,
const wxPoint& pos,
const wxSize& size)
}
}
- m_hWnd = (WXHWND)::CreateDialog(wxGetInstance(),
- dlgTemplate,
- parent ? GetHwndOf(parent) : NULL,
- (DLGPROC)wxDlgProc);
+ m_hWnd = (WXHWND)::CreateDialogIndirect
+ (
+ wxGetInstance(),
+ (DLGTEMPLATE*)dlgTemplate,
+ parent ? GetHwndOf(parent) : NULL,
+ (DLGPROC)wxDlgProc
+ );
if ( !m_hWnd )
{
- wxFAIL_MSG(_("Did you forget to include wx/msw/wx.rc in your resources?"));
+ wxFAIL_MSG(_("Failed to create dialog. Incorrect DLGTEMPLATE?"));
- wxLogSysError(_("Can't create dialog using template '%s'"), dlgTemplate);
+ wxLogSysError(_("Can't create dialog using memory template"));
return FALSE;
}
- long exflags;
+ WXDWORD exflags;
(void)MSWGetCreateWindowFlags(&exflags);
if ( exflags )
const wxPoint& pos,
const wxSize& size)
{
- long exflags;
- long flags = MSWGetCreateWindowFlags(&exflags);
+ WXDWORD exflags;
+ WXDWORD flags = MSWGetCreateWindowFlags(&exflags);
return MSWCreate(wxCanvasClassName, title, pos, size, flags, exflags);
}
if ( GetExtraStyle() & wxTOPLEVEL_EX_DIALOG )
{
- // TODO: it would be better to construct the dialog template in memory
- // during run-time than to rely on the limited number of
- // templates in wx.rc because:
- // a) you wouldn't have to include wx.rc in all wxWin programs
- // (and the number of complaints about it would dtop)
- // b) we'd be able to provide more templates simply, i.e.
- // we could generate the templates for all style
- // combinations
-
// we have different dialog templates to 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)
- const wxChar *dlgTemplate;
- if ( style & wxRESIZE_BORDER )
- dlgTemplate = wxT("wxResizeableDialog");
- else if ( style & wxCAPTION )
- dlgTemplate = wxT("wxCaptionDialog");
- else
- dlgTemplate = wxT("wxNoCaptionDialog");
-
- return CreateDialog(dlgTemplate, title, pos, size);
+
+ // we need 3 additional WORDs for dialog menu, class and title (as we
+ // don't use DS_SETFONT we don't need the fourth WORD for the font)
+ static const int dlgsize = sizeof(DLGTEMPLATE) + (sizeof(WORD) * 3);
+ DLGTEMPLATE *dlgTemplate = (DLGTEMPLATE *)malloc(dlgsize);
+ memset(dlgTemplate, 0, dlgsize);
+
+ // these values are arbitrary, they won't be used normally anyhow
+ dlgTemplate->x = 34;
+ dlgTemplate->y = 22;
+ dlgTemplate->cx = 144;
+ dlgTemplate->cy = 75;
+
+ // reuse the code in MSWGetStyle() but correct the results slightly for
+ // the dialog
+ dlgTemplate->style = MSWGetStyle(style, NULL);
+
+ // all dialogs are popups
+ dlgTemplate->style |= WS_POPUP;
+
+ // force 3D-look if necessary, it looks impossibly ugly otherwise
+ if ( style & (wxRESIZE_BORDER | wxCAPTION) )
+ dlgTemplate->style |= DS_MODALFRAME;
+
+ bool ret = CreateDialog(dlgTemplate, title, pos, size);
+ free(dlgTemplate);
+
+ return ret;
}
else // !dialog
{