From: Julian Smart Date: Fri, 15 Jun 2001 12:59:22 +0000 (+0000) Subject: Sync'ed show-window flag in MDI child constructor; added initial wxKill implementation X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e949bf13c5a79f20b91eaed882d3246b1023718f Sync'ed show-window flag in MDI child constructor; added initial wxKill implementation for wxMSW git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 8ab7af988c..46f92ba543 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -650,6 +650,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, : wxDEFAULT_MDICHILDFRAME_ICON); SetName(name); + wxWindowBase::Show(TRUE); // MDI child frame starts off shown if ( id > -1 ) m_windowId = id; diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 8e907f1bd2..171942f093 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -513,11 +513,65 @@ bool wxSetEnv(const wxString& var, const wxChar *value) // 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