X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dfb06c62ffda093aecdf8ab0f9e405a2f3dfb332..7d0180d415f3cce126abebed2ef1d0fde00bcc61:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 6530437b94..0c5ef7d3b3 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -101,20 +101,24 @@ void wxTopLevelWindowMSW::Init() 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 // // 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 - long msflags; 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 ) @@ -141,9 +145,6 @@ long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const 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 ) @@ -157,8 +158,6 @@ long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const if ( exflags ) { - *exflags = MakeExtendedStyle(style); - #if !defined(__WIN16__) && !defined(__SC__) if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ) { @@ -177,7 +176,7 @@ long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const *exflags |= WS_EX_TOPMOST; #ifdef __WIN32__ - if ( m_exStyle & wxFRAME_EX_CONTEXTHELP ) + if ( GetExtraStyle() & wxFRAME_EX_CONTEXTHELP ) *exflags |= WS_EX_CONTEXTHELP; #endif // __WIN32__ } @@ -185,7 +184,7 @@ long wxTopLevelWindowMSW::MSWGetCreateWindowFlags(long *exflags) const return msflags; } -bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate, +bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, const wxString& title, const wxPoint& pos, const wxSize& size) @@ -218,21 +217,24 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate, } } - 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 ) @@ -315,8 +317,8 @@ bool wxTopLevelWindowMSW::CreateFrame(const wxString& title, 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); } @@ -345,28 +347,38 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, 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 {