]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/utilsexc.cpp
added some utils (tex2rtf, helpgen, makegen) to make system
[wxWidgets.git] / src / msw / utilsexc.cpp
index 9d778c9d5b67475fa7d9922d1b88a9fc3ffe9eb9..5cbd5a4957dd0a5035eb4ee7a5970c233de5bfbc 100644 (file)
@@ -167,9 +167,13 @@ LRESULT APIENTRY _EXPORT wxExecuteWindowCbk(HWND hWnd, UINT message,
             // asynchronous execution - we should do the clean up
             delete data;
         }
             // asynchronous execution - we should do the clean up
             delete data;
         }
-    }
 
 
-    return 0;
+        return 0;
+    }
+    else
+    {
+        return DefWindowProc(hWnd, message, wParam, lParam);
+    }
 }
 #endif
 
 }
 #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
                          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)
                          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;
     }
 
         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");
     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)");
         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,
         }
     }
 
     // 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") );
 
                                (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);
 
                                     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");
     if ( !hThread )
     {
         wxLogLastError("CreateThread in wxExecute");
@@ -333,10 +346,20 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
         return pi.dwProcessId;
     }
 
         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();
 
     while ( data->state )
         wxYield();
 
+#if wxUSE_GUI
+    wxEnableTopLevelWindows(TRUE);
+    wxEndBusyCursor();
+#endif // wxUSE_GUI
+
     DWORD dwExitCode = data->dwExitCode;
     delete data;
 
     DWORD dwExitCode = data->dwExitCode;
     delete data;
 
@@ -373,3 +396,36 @@ long wxExecute(char **argv, bool sync, wxProcess *handler)
     return wxExecute(command, sync, 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);
+}