X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a23fd0e1d1329a4a258b4defb3e0b0001b700c6e..438e3558adf77a68f56b6e4d30b359f8361facac:/src/msw/dialog.cpp diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index f58e8d9693..2820cfaa33 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -26,6 +26,8 @@ #include "wx/frame.h" #include "wx/app.h" #include "wx/settings.h" +#include "wx/intl.h" +#include "wx/log.h" #endif #include "wx/msw/private.h" @@ -44,7 +46,6 @@ wxWindowList wxModalDialogs; wxWindowList wxModelessWindows; // Frames and modeless dialogs extern wxList WXDLLEXPORT wxPendingDelete; -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel) @@ -56,7 +57,6 @@ extern wxList WXDLLEXPORT wxPendingDelete; EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged) EVT_CLOSE(wxDialog::OnCloseWindow) END_EVENT_TABLE() -#endif wxDialog::wxDialog() { @@ -120,13 +120,13 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, // 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 char *dlg; - if ( style & wxTHICK_FRAME ) - dlg = "wxResizeableDialog"; + const wxChar *dlg; + if ( style & wxRESIZE_BORDER ) + dlg = wxT("wxResizeableDialog"); else if ( style & wxCAPTION ) - dlg = "wxCaptionDialog"; + dlg = wxT("wxCaptionDialog"); else - dlg = "wxNoCaptionDialog"; + dlg = wxT("wxNoCaptionDialog"); MSWCreate(m_windowId, parent, NULL, this, NULL, x, y, width, height, 0, // style is not used if we have dlg template @@ -169,9 +169,10 @@ wxDialog::~wxDialog() wxTopLevelWindows.DeleteObject(this); + Show(FALSE); + if (m_modalShowing) { - Show(FALSE); // For some reason, wxWindows can activate another task altogether // when a frame is destroyed after a modal dialog has been invoked. // Try to bring the parent to the top. @@ -183,14 +184,10 @@ wxDialog::~wxDialog() } m_modalShowing = FALSE; - if ( GetHWND() ) - ShowWindow((HWND) GetHWND(), SW_HIDE); if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) wxModelessWindows.DeleteObject(this); - UnsubclassWin(); - // If this is the last top-level window, exit. if (wxTheApp && (wxTopLevelWindows.Number() == 0)) { @@ -216,6 +213,9 @@ void wxDialog::OnCharHook(wxKeyEvent& event) cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); + // ensure that there is another message for this window so the + // ShowModal loop will exit and won't get stuck in GetMessage(). + ::PostMessage(GetHwnd(), WM_NULL, 0, 0); return; } } @@ -282,6 +282,11 @@ bool wxDialog::IsShown() const return m_isShown; } +bool wxDialog::IsModal() const +{ + return wxModalDialogs.Find((wxDialog *)this) != 0; // const_cast +} + bool wxDialog::Show(bool show) { m_isShown = show; @@ -310,7 +315,13 @@ bool wxDialog::Show(bool show) { if (show) { - m_hwndOldFocus = (WXHWND)::GetFocus(); + // find the top level window which had focus before - we will restore + // focus to it later + m_hwndOldFocus = 0; + for ( HWND hwnd = ::GetFocus(); hwnd; hwnd = ::GetParent(hwnd) ) + { + m_hwndOldFocus = (WXHWND)hwnd; + } if (m_modalShowing) { @@ -464,7 +475,9 @@ bool wxDialog::Show(bool show) if (hWndParent) ::BringWindowToTop(hWndParent); } - ShowWindow((HWND) GetHWND(), SW_HIDE); + + if ( m_hWnd ) + ShowWindow((HWND) GetHWND(), SW_HIDE); } } return TRUE; @@ -472,7 +485,7 @@ bool wxDialog::Show(bool show) void wxDialog::SetTitle(const wxString& title) { - SetWindowText((HWND) GetHWND(), (const char *)title); + SetWindowText((HWND) GetHWND(), title.c_str()); } wxString wxDialog::GetTitle() const @@ -627,3 +640,27 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) Refresh(); #endif } + +// --------------------------------------------------------------------------- +// dialog window proc +// --------------------------------------------------------------------------- + +long wxDialog::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +{ + long rc = 0; + bool processed = FALSE; + + switch ( message ) + { + case WM_CLOSE: + // if we can't close, tell the system that we processed the + // message - otherwise it would close us + processed = !Close(); + break; + } + + if ( !processed ) + rc = wxWindow::MSWWindowProc(message, wParam, lParam); + + return rc; +}