From ac20ecd8f176afa3bc9424c4d02b95d5c41ed040 Mon Sep 17 00:00:00 2001 From: Nicola Carminati Date: Tue, 30 Jul 2019 10:27:02 +0200 Subject: [PATCH] Fix Window manager Siemens --- Client/View/NcWindow.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Client/View/NcWindow.cs b/Client/View/NcWindow.cs index ba90ea4b..1f7770d9 100644 --- a/Client/View/NcWindow.cs +++ b/Client/View/NcWindow.cs @@ -100,7 +100,10 @@ namespace Active_Client.View private static int ActiveNCWindowStyle; private static int ActiveNCWindowBorder; private static int ActiveWindowNCWindowStyle; - private static int ActiveWindowNCWindowBorder; + private static int ActiveWindowNCWindowBorder; + private static uint ActiveWindowNCPopUp; + private static uint ActiveNCWindowNCPopUp; + public static MainForm mainFrm; private static string prodEXEname; @@ -645,7 +648,7 @@ namespace Active_Client.View UnhookWinEvent(hhookWindow); //Attach the OSAI hook - if (windowstarted && Config.VendorHmiConfig.Type == 3) + if (windowstarted && (Config.VendorHmiConfig.Type == 2 || Config.VendorHmiConfig.Type == 3)) { procDelegateWindow = new WinEventDelegate(WinEventProcWindow); hhookWindow = SetWinEventHook(EVENT_OBJECT_CREATE, EVENT_OBJECT_DESTROY, IntPtr.Zero, procDelegateWindow, 0, 0, WINEVENT_OUTOFCONTEXT); @@ -987,9 +990,10 @@ namespace Active_Client.View //Find if it has the border ActiveWindowNCWindowBorder = (ActiveWindowNCWindowStyle & WS_BORDER); + ActiveWindowNCPopUp = ((uint)ActiveWindowNCWindowStyle & WS_POPUP); //if it has the border and a title execute focus - if (ActiveWindowNCWindowStyle != 0 && ActiveWindowNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "") + if (ActiveWindowNCWindowStyle != 0 && (((ActiveWindowNCWindowBorder == WS_BORDER) && ReadWindowTitle(hwnd) != "") || (ActiveWindowNCPopUp == WS_POPUP) )) { if (eventType == EVENT_OBJECT_CREATE) { @@ -1021,10 +1025,11 @@ namespace Active_Client.View ActiveNCWindowStyle = GetWindowLong(hwnd, GWL_STYLE); //Find if it has the border ActiveNCWindowBorder = (ActiveNCWindowStyle & WS_BORDER); + ActiveNCWindowNCPopUp = ((uint)ActiveWindowNCWindowStyle & WS_POPUP); //if it has the border and a title execute focus - if (ActiveNCWindowStyle != 0 && ActiveNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "" && hwnd != ncprocess.MainWindowHandle) + if (ActiveNCWindowStyle != 0 && ((ActiveNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "") || (ActiveNCWindowNCPopUp == WS_POPUP)) && hwnd != ncprocess.MainWindowHandle) { SetWindowPos(ncprocess.MainWindowHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW); }