]> git.saurik.com Git - wxWidgets.git/commitdiff
Sync'ed show-window flag in MDI child constructor; added initial wxKill implementation
authorJulian Smart <julian@anthemion.co.uk>
Fri, 15 Jun 2001 12:59:22 +0000 (12:59 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 15 Jun 2001 12:59:22 +0000 (12:59 +0000)
for wxMSW

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/mdi.cpp
src/msw/utils.cpp

index 8ab7af988c6a09a829c42bd8afe27b81a5dc47ed..46f92ba543237f9e2bdfc63293c8227c63c07e1f 100644 (file)
@@ -650,6 +650,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
                                                      : wxDEFAULT_MDICHILDFRAME_ICON);
 
   SetName(name);
                                                      : wxDEFAULT_MDICHILDFRAME_ICON);
 
   SetName(name);
+  wxWindowBase::Show(TRUE); // MDI child frame starts off shown
 
   if ( id > -1 )
     m_windowId = id;
 
   if ( id > -1 )
     m_windowId = id;
index 8e907f1bd26f027d5c67d4abd90755c9102c480e..171942f093c432c3c3afcb80834c2c91dabec8bd 100644 (file)
@@ -513,11 +513,65 @@ bool wxSetEnv(const wxString& var, const wxChar *value)
 // process management
 // ----------------------------------------------------------------------------
 
 // process management
 // ----------------------------------------------------------------------------
 
-int wxKill(long WXUNUSED(pid), int WXUNUSED(sig))
+int wxKill(long pid, wxSignal sig)
 {
 {
-    // TODO use SendMessage(WM_QUIT) and TerminateProcess() if needed
+#ifndef __WIN32__
+    return -1;
+#else
+    // This in a work in progress. We need to eliminate the call to wxSleep,
+    // deal with child processes, and also test it :-)
+    HWND hHwnd;
+    HANDLE hProcess;
+    unsigned long code;
+    bool terminateSuccess = TRUE;
+
+    hProcess = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION,
+                           FALSE, (unsigned long)pid);
+    if (hProcess == NULL)
+        return -1;
+
+    if (sig == wxSIGKILL)
+        terminateSuccess = (TerminateProcess(hProcess, 0) != 0);
+    else if (sig != wxSIGNONE)
+    {
+        hHwnd = ::FindWindow(NULL, NULL);
+        while (hHwnd != 0)
+        {
+            if (::GetParent(hHwnd) == 0)
+            {
+                unsigned long testpid = 0;
+                GetWindowThreadProcessId(hHwnd, &testpid);
+                if ((unsigned long)pid == testpid)
+                {
+                    PostMessage(hHwnd, WM_QUIT, 0, 0);
+                    // How to make this better?
+                    // If we don't wait, the return value is wrong.
+                    wxSleep(1);
+                    break;
+                }
+            }
+            hHwnd = GetWindow(hHwnd, GW_HWNDNEXT);
+        }
+    }
 
 
-    return 0;
+    GetExitCodeProcess(hProcess, &code);
+    CloseHandle(hProcess);
+
+    if (sig == wxSIGNONE)
+    {
+        if (code == STILL_ACTIVE)
+            return 0;
+        else
+            return -1;
+    }
+    else
+    {
+        if (!terminateSuccess || code == STILL_ACTIVE)
+            return -1;
+        else
+            return 0;
+    }
+#endif
 }
 
 // Execute a program in an Interactive Shell
 }
 
 // Execute a program in an Interactive Shell