From: Vadim Zeitlin Date: Sun, 8 Sep 2002 00:40:57 +0000 (+0000) Subject: fixed wxExecute() for console programs (process messagse for the hidden window, don... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/45d5a0c6d884a616ddbac796192032a384c7ba85?ds=inline fixed wxExecute() for console programs (process messagse for the hidden window, don't hang) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17067 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index db4da1ef05..58b26f2c07 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -33,9 +33,9 @@ #include "wx/app.h" #include "wx/intl.h" #include "wx/log.h" -#if wxUSE_GUI // See 'dirty hack' below. - #include "wx/frame.h" -#endif + #if wxUSE_GUI // See 'dirty hack' below. + #include "wx/frame.h" + #endif #endif #ifdef __WIN32__ @@ -262,7 +262,7 @@ private: // thread function for the thread monitoring the process termination static DWORD __stdcall wxExecuteThread(void *arg) { - wxExecuteData *data = (wxExecuteData*)arg; + wxExecuteData * const data = (wxExecuteData *)arg; if ( ::WaitForSingleObject(data->hProcess, INFINITE) != WAIT_OBJECT_0 ) { @@ -293,7 +293,7 @@ LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message, { DestroyWindow(hWnd); // we don't need it any more - wxExecuteData *data = (wxExecuteData *)lParam; + wxExecuteData * const data = (wxExecuteData *)lParam; if ( data->handler ) { data->handler->OnTerminate((int)data->dwProcessId, @@ -316,7 +316,7 @@ LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message, } else { - return DefWindowProc(hWnd, message, wParam, lParam); + return ::DefWindowProc(hWnd, message, wParam, lParam); } } @@ -899,8 +899,15 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler) // real async IO which we don't have for the moment ::Sleep(50); +#if wxUSE_GUI // repaint the GUI wxYield(); +#else // !GUI + // dispatch the messages to the hidden window so that it could + // process the wxWM_PROC_TERMINATED notification + MSG msg; + ::PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE); +#endif // GUI/!GUI } #if wxUSE_GUI