diff --git a/xvaga/oswin32.cpp b/xvaga/oswin32.cpp index d83402d91..0d8a477db 100755 --- a/xvaga/oswin32.cpp +++ b/xvaga/oswin32.cpp @@ -597,16 +597,16 @@ static BOOL CALLBACK EnumCampoChildrenProc(HWND hwnd, LPARAM lParam) return TRUE; } -static BOOL CALLBACK EnumCampoWindowsProc(HWND hwnd, LPARAM lParam) +static BOOL CALLBACK EnumCampoMenuChildrenProc(HWND hwnd, LPARAM lParam) { char str[_MAX_PATH]; if (::GetWindowText(hwnd, str, sizeof(str))) { const wxString title = str; - if (title.StartsWith("Base - ")) + if (title.StartsWith("Base - ")) // Scandisco solo i figli del menu { ::EnumChildWindows(hwnd, EnumCampoChildrenProc, lParam); - TFindWindowInfo* w = (TFindWindowInfo*)lParam; + const TFindWindowInfo* w = (TFindWindowInfo*)lParam; if (w->_hwnd != NULL) return FALSE; } @@ -614,12 +614,11 @@ static BOOL CALLBACK EnumCampoWindowsProc(HWND hwnd, LPARAM lParam) return TRUE; } - unsigned int OsWin32_FindMenuContainer() { TFindWindowInfo w; w._file = "__CAMPO_HOST_WINDOW__"; - ::EnumWindows(EnumCampoWindowsProc, LPARAM(&w)); + ::EnumWindows(EnumCampoMenuChildrenProc, LPARAM(&w)); return (unsigned int)w._hwnd; } @@ -650,6 +649,30 @@ long OsWin32_CloseChildren(unsigned int parent) return n; } +static BOOL CALLBACK CloseSiblingProc(HWND hwnd, LPARAM lParam) +{ + if (hwnd != (HWND)lParam) + { + if (!::IsWindowVisible(hwnd)) + { + char str[256]; + ::GetClassName(hwnd, str, sizeof(str)); + if (strcmp(str, "wxWindowClassNR") == 0) + { + ::GetWindowText(hwnd, str, sizeof(str)); + if (str[0] == '\0') + ::PostMessage(hwnd, WM_ENDSESSION, 0, 0); + } + } + } + return TRUE; +} + +void OsWin32_CloseSiblings(unsigned int parent) +{ + ::EnumWindows(CloseSiblingProc, parent); +} + /////////////////////////////////////////////////////////// // Hardlock Support /////////////////////////////////////////////////////////// diff --git a/xvaga/oswin32.h b/xvaga/oswin32.h index 7674ec2d2..b0dd19afa 100755 --- a/xvaga/oswin32.h +++ b/xvaga/oswin32.h @@ -19,6 +19,7 @@ void OsWin32_PlaceProcessInWindow(unsigned int instance, const char* name, unsig unsigned int OsWin32_FindMenuContainer(); long OsWin32_GetChildrenCount(unsigned int parent); long OsWin32_CloseChildren(unsigned int parent); +void OsWin32_CloseSiblings(unsigned int parent); void OsWin32_UpdateWindow(unsigned int handle); void OsWin32_NumberFormat(char* str, int size); diff --git a/xvaga/xvaga.cpp b/xvaga/xvaga.cpp index 3fd18917f..836b5c02f 100755 --- a/xvaga/xvaga.cpp +++ b/xvaga/xvaga.cpp @@ -3662,6 +3662,16 @@ long xvt_sys_close_children(WINDOW win) return c; } +long xvt_sys_close_siblings(WINDOW win) +{ + long c = 0; // Non sto a perder tempo a contarli :-) +#ifdef WIN32 + CAST_WIN(win, w); + OsWin32_CloseSiblings((unsigned int)w.GetHandle()); +#endif + return c; +} + BOOLEAN xvt_sys_goto_url(const char* url, const char* action) { #ifdef WIN32 @@ -3678,7 +3688,7 @@ BOOLEAN xvt_sys_dongle_server_is_running() BOOLEAN ok = sic.IsAnotherRunning(); #ifdef WIN32 - if (!ok) // Testo anche Frontend! + if (!ok) // Testo anche il buon vecchio Frontend! ok = ::GlobalFindAtom("DONGLE_SERVER_ATOM") != 0; #endif diff --git a/xvaga/xvt.h b/xvaga/xvt.h index 95ab52cfe..df9677073 100755 --- a/xvaga/xvt.h +++ b/xvaga/xvt.h @@ -365,6 +365,7 @@ XVTDLL void xvt_sys_beep(int severity); XVTDLL long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask); XVTDLL long xvt_sys_execute_in_window(const char* cmdline, WINDOW win); XVTDLL long xvt_sys_close_children(WINDOW win); +XVTDLL long xvt_sys_close_siblings(WINDOW win); XVTDLL BOOLEAN xvt_sys_get_host_name(char* name, int maxlen); XVTDLL BOOLEAN xvt_sys_get_user_name(char* name, int maxlen); diff --git a/xvaga/xvtwin.cpp b/xvaga/xvtwin.cpp index 7ca24bb6b..57750e91d 100755 --- a/xvaga/xvtwin.cpp +++ b/xvaga/xvtwin.cpp @@ -1002,6 +1002,7 @@ BEGIN_EVENT_TABLE(TTaskWin, wxFrame) EVT_MENU_RANGE(1000, 32766, TTaskWin::OnMenu) EVT_PAINT(TTaskWin::OnPaint) EVT_SIZE(TTaskWin::OnSize) + EVT_END_SESSION(TTaskWin::OnClose) END_EVENT_TABLE() void TTaskWin::OnClose(wxCloseEvent& evt)