X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82c9f85ce5aceaa3aedac7e690070d5eff904e5b..ef3a5e0aae003c29941c7d41ed6becea4287752d:/src/msw/dialog.cpp diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index d612844e9c..7a3531d84b 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -113,118 +113,16 @@ bool wxDialog::Create(wxWindow *parent, SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); - if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) - return FALSE; - + // save focus before doing anything which can potentially change it m_oldFocus = FindFocus(); - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; - - if (x < 0) - x = wxDIALOG_DEFAULT_X; - if (y < 0) - y = wxDIALOG_DEFAULT_Y; - - if (width < 0) - width = wxDIALOG_DEFAULT_WIDTH; - if (height < 0) - height = wxDIALOG_DEFAULT_HEIGHT; - // All dialogs should really have this style - m_windowStyle |= wxTAB_TRAVERSAL; - - WXDWORD extendedStyle = MakeExtendedStyle(m_windowStyle); - if (m_windowStyle & wxSTAY_ON_TOP) - extendedStyle |= WS_EX_TOPMOST; - -#ifndef __WIN16__ - 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) - const wxChar *dlg; - if ( style & wxRESIZE_BORDER ) - dlg = wxT("wxResizeableDialog"); - else if ( style & wxCAPTION ) - dlg = wxT("wxCaptionDialog"); - else - dlg = wxT("wxNoCaptionDialog"); - -#ifdef __WXMICROWIN__ - extern const wxChar *wxFrameClassName; - - int msflags = WS_OVERLAPPED|WS_POPUP; - if (style & wxCAPTION) - msflags |= WS_CAPTION; - if (style & wxCLIP_CHILDREN) - msflags |= WS_CLIPCHILDREN; - if ((style & wxTHICK_FRAME) == 0) - msflags |= WS_BORDER; - MSWCreate(m_windowId, parent, wxFrameClassName, this, NULL, - x, y, width, height, - msflags, - NULL, - extendedStyle); - -#else - MSWCreate(m_windowId, parent, NULL, this, NULL, - x, y, width, height, - 0, // style is not used if we have dlg template - dlg, - extendedStyle); -#endif - HWND hwnd = (HWND)GetHWND(); - - if ( !hwnd ) - { - wxFAIL_MSG(_("Failed to create dialog. You probably forgot to include wx/msw/wx.rc in your resources.")); - - return FALSE; - } - -#ifndef __WXMICROWIN__ - SubclassWin(GetHWND()); -#endif - - SetWindowText(hwnd, title); - - return TRUE; -} - -bool wxDialog::EnableCloseButton(bool enable) -{ -#ifndef __WXMICROWIN__ - // get system (a.k.a. window) menu - HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE /* get it */); - if ( !hmenu ) - { - wxLogLastError(_T("GetSystemMenu")); - - return FALSE; - } - - // enabling/disabling the close item from it also automatically - // disables/enabling the close title bar button - if ( !::EnableMenuItem(hmenu, SC_CLOSE, - MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED)) ) - { - wxLogLastError(_T("EnableMenuItem(SC_CLOSE)")); + style |= wxTAB_TRAVERSAL; + if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return FALSE; - } - // update appearance immediately - if ( !::DrawMenuBar(GetHwnd()) ) - { - wxLogLastError(_T("DrawMenuBar")); - } -#endif + SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); return TRUE; } @@ -392,18 +290,6 @@ bool wxDialog::Show(bool show) { // use it m_parent = parent; - - // VZ: to make dialog behave properly we should reparent - // the dialog for Windows as well - unfortunately, - // following the docs for SetParent() results in this - // code which plainly doesn't work -#if 0 - long dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE); - dwStyle &= ~WS_POPUP; - dwStyle |= WS_CHILD; - ::SetWindowLong(GetHwnd(), GWL_STYLE, dwStyle); - ::SetParent(GetHwnd(), GetHwndOf(parent)); -#endif // 0 } }