X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a543e3ce7e0691f771f245bcf5402cd1fbd2b829..f35746ceeda33434574d667f81d7e6e8b18b7c46:/src/msw/dialog.cpp diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 748ef0595f..8c5390cc5c 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -5,7 +5,7 @@ // Modified by: // Created: 01/02/97 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -191,7 +191,7 @@ bool wxDialog::IsModal() const bool wxDialog::IsModalShowing() const { - return wxModalDialogs.Find((wxDialog *)this) != NULL; // const_cast + return wxModalDialogs.Find(wxConstCast(this, wxDialog)) != NULL; } wxWindow *wxDialog::FindSuitableParent() const @@ -247,6 +247,12 @@ void wxDialog::DoShowModal() m_windowDisabler = new wxWindowDisabler(this); + // before entering the modal loop, reset the "is in OnIdle()" flag (see + // comment in app.cpp) + extern bool wxIsInOnIdleFlag; + bool wasInOnIdle = wxIsInOnIdleFlag; + wxIsInOnIdleFlag = FALSE; + // enter the modal loop while ( IsModalShowing() ) { @@ -261,6 +267,8 @@ void wxDialog::DoShowModal() wxTheApp->DoMessage(); } + wxIsInOnIdleFlag = wasInOnIdle; + // and restore focus // Note that this code MUST NOT access the dialog object's data // in case the object has been deleted (which will be the case @@ -296,6 +304,14 @@ bool wxDialog::Show(bool show) if ( show ) { + // dialogs don't get WM_SIZE message after creation unlike most (all?) + // other windows and so could start their life non laid out correctly + // if we didn't call Layout() from here + // + // NB: normally we should call it just the first time but doing it + // every time is simpler than keeping a flag + Layout(); + // usually will result in TransferDataToWindow() being called InitDialog(); } @@ -317,12 +333,21 @@ bool wxDialog::Show(bool show) // this will cause IsModalShowing() return FALSE and our local // message loop will terminate wxModalDialogs.DeleteObject(this); + + // 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 TRUE; } +void wxDialog::Raise() +{ + ::SetForegroundWindow(GetHwnd()); +} + // a special version for Show(TRUE) for modal dialogs which returns return code int wxDialog::ShowModal() {