diff --git a/include/wx/utils.h b/include/wx/utils.h index 222e822c5b..c18128a791 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -171,6 +171,9 @@ WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, con // Yield to other apps/messages WXDLLEXPORT bool wxYield(); +// Yield to other apps/messages and disable user input +WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL); + // Format a message on the standard error (UNIX) or the debugging // stream (Windows) WXDLLEXPORT void wxDebugMsg(const char *fmt ...) ; diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index f15e7f0bbd..be9df90d2f 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -748,6 +748,27 @@ whereami(name) #endif + +// Yield to other apps/messages and disable user input +bool wxSafeYield(wxWindow *win) +{ + wxNode *node; + for ( node = wxTopLevelWindows.GetFirst(); + node; + node = node->GetNext() ) + ((wxWindow*)node->GetData())->Enable(FALSE); + + // always enable ourselves + if(win) win->Enable(true); + bool rc = wxYield(); + + for ( node = wxTopLevelWindows.GetFirst(); + node; + node = node->GetNext() ) + ((wxWindow*)node->GetData())->Enable(TRUE); + return rc; +} + /* * N.B. these convenience functions must be separate from msgdlgg.cpp, textdlgg.cpp * since otherwise the generic code may be pulled in unnecessarily.