X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b568d04ffa191f9e3b643ca33526094eca0ba304..37b8e6798782278fdfe4f3c1291aaff55cdbb8c9:/src/msw/utilsexc.cpp?ds=inline diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index 9d778c9d5b..5cbd5a4957 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -167,9 +167,13 @@ LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message, // asynchronous execution - we should do the clean up delete data; } - } - return 0; + return 0; + } + else + { + return DefWindowProc(hWnd, message, wParam, lParam); + } } #endif @@ -247,7 +251,8 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler) NULL, // security attributes: defaults for both NULL, // the process and its main thread FALSE, // don't inherit handles - CREATE_DEFAULT_ERROR_MODE, // flags + CREATE_DEFAULT_ERROR_MODE | + CREATE_SUSPENDED, // flags NULL, // environment (use the same) NULL, // current directory (use the same) &si, // startup info (unused here) @@ -259,10 +264,7 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler) return 0; } - // close unneeded handle - if ( !::CloseHandle(pi.hThread) ) - wxLogLastError("CloseHandle(hThread)"); - + // register the class for the hidden window used for the notifications if ( !gs_classForHiddenWindow ) { gs_classForHiddenWindow = _T("wxHiddenWindow"); @@ -276,15 +278,14 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler) if ( !::RegisterClass(&wndclass) ) { wxLogLastError("RegisterClass(hidden window)"); - - return FALSE; } } // create a hidden window to receive notification about process // termination HWND hwnd = ::CreateWindow(gs_classForHiddenWindow, NULL, - 0, 0, 0, 0, 0, NULL, + WS_OVERLAPPEDWINDOW, + 0, 0, 0, 0, NULL, (HMENU)NULL, wxGetInstance(), 0); wxASSERT_MSG( hwnd, wxT("can't create a hidden window for wxExecute") ); @@ -314,6 +315,18 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler) 0, &tid); + // resume process we created now - whether the thread creation succeeded or + // not + if ( ::ResumeThread(pi.hThread) == (DWORD)-1 ) + { + // ignore it - what can we do? + wxLogLastError("ResumeThread in wxExecute"); + } + + // close unneeded handle + if ( !::CloseHandle(pi.hThread) ) + wxLogLastError("CloseHandle(hThread)"); + if ( !hThread ) { wxLogLastError("CreateThread in wxExecute"); @@ -333,10 +346,20 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler) return pi.dwProcessId; } - // waiting until command executed + // waiting until command executed (disable everything while doing it) +#if wxUSE_GUI + wxBeginBusyCursor(); + wxEnableTopLevelWindows(FALSE); +#endif // wxUSE_GUI + while ( data->state ) wxYield(); +#if wxUSE_GUI + wxEnableTopLevelWindows(TRUE); + wxEndBusyCursor(); +#endif // wxUSE_GUI + DWORD dwExitCode = data->dwExitCode; delete data; @@ -373,3 +396,36 @@ long wxExecute(char **argv, bool sync, wxProcess *handler) return wxExecute(command, sync, handler); } +// ---------------------------------------------------------------------------- +// Metafile helpers +// ---------------------------------------------------------------------------- + +extern void PixelToHIMETRIC(LONG *x, LONG *y) +{ + ScreenHDC hdcRef; + + int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE), + iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE), + iWidthPels = GetDeviceCaps(hdcRef, HORZRES), + iHeightPels = GetDeviceCaps(hdcRef, VERTRES); + + *x *= (iWidthMM * 100); + *x /= iWidthPels; + *y *= (iHeightMM * 100); + *y /= iHeightPels; +} + +extern void HIMETRICToPixel(LONG *x, LONG *y) +{ + ScreenHDC hdcRef; + + int iWidthMM = GetDeviceCaps(hdcRef, HORZSIZE), + iHeightMM = GetDeviceCaps(hdcRef, VERTSIZE), + iWidthPels = GetDeviceCaps(hdcRef, HORZRES), + iHeightPels = GetDeviceCaps(hdcRef, VERTRES); + + *x *= iWidthPels; + *x /= (iWidthMM * 100); + *y *= iHeightPels; + *y /= (iHeightMM * 100); +}