Fix NC Window behaviour

This commit is contained in:
Nicola Carminati
2019-05-17 14:27:39 +02:00
parent ee4c80d013
commit c2e8df0c09
2 changed files with 18 additions and 13 deletions
+2 -1
View File
@@ -123,8 +123,9 @@ namespace Active_Client.View
NcWindow.ShowTaskBar();
NcWindow.MinimizeNcWindow();
if (Config.VendorHmiConfig.Type == 3)
NcWindow.HideNcWindow();
NcWindow.MinimizeProdWindow();
HideAUXWindow();
}
else
{
+16 -12
View File
@@ -991,8 +991,10 @@ namespace Active_Client.View
//if it has the border and a title execute focus
if (ActiveWindowNCWindowStyle != 0 && ActiveWindowNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "")
{
if (eventType == EVENT_OBJECT_CREATE && state == NcState.SHOW)
if (eventType == EVENT_OBJECT_CREATE)
{
SetForegroundWindow(ncprocess.MainWindowHandle);
}
else if (eventType == EVENT_OBJECT_DESTROY)
SetWindowPos(MainViewHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
@@ -1010,7 +1012,6 @@ namespace Active_Client.View
//Read the actual ID of the Process
GetWindowThreadProcessId(hwnd, out ActualPID);
Console.WriteLine(ReadWindowTitle(hwnd));
//Delete the TOPMOST Style of the Window
if (NcProcessPID != 0 && ActualPID == NcProcessPID)
@@ -1025,7 +1026,7 @@ namespace Active_Client.View
//if it has the border and a title execute focus
if (ActiveNCWindowStyle != 0 && ActiveNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "" && hwnd != ncprocess.MainWindowHandle)
{
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
SetWindowPos(ncprocess.MainWindowHandle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
}
@@ -1035,10 +1036,6 @@ namespace Active_Client.View
{
if (!IsIconic(MainViewHandle))
{
//Hide the TaskBar
if (Environment.OSVersion.Version.Major < 10)
HideTaskBar();
//Show Virtual keyboard
if (Config.ClientConfig.ShowVirtualKeyboard && Environment.OSVersion.Version.Major < 10)
reOpenVirtualKeyboard();
@@ -1051,9 +1048,6 @@ namespace Active_Client.View
if (Environment.OSVersion.Version.Major < 10)
HideTaskBar();
//if (LastHookedPID != MainProcessPID && LastHookedPID != NcProcessPID && LastHookedPID != ProdProcessPID)
//SetForegroundWindow(MainViewHandle);
}
//If the PID is OTHER Process
else
@@ -1404,11 +1398,21 @@ namespace Active_Client.View
//NC Following Method
public static void FollowNcBehaviour()
{
{
uint process = 0;
try
{
while (true)
{
{
GetWindowThreadProcessId(GetForegroundWindow(), out process);
if (state != NcState.SHOW && state != NcState.SHOWPROD && (process == NcProcessPID || process == ProdProcessPID))
mainFrm.HideAUXWindow();
else if (state == NcState.SHOWPROD && process == NcProcessPID && prodwindowstarted)
mainFrm.ShowProdWindow();
else if (state == NcState.SHOW && process == ProdProcessPID && windowstarted)
mainFrm.ShowNCWindow();
if (Process.GetProcessesByName(processname).Length == 0)
{
//Un-parent the window