Trying yet another function to bring to foreground but it's broken too.
authorStephaneLenclud
Thu, 19 Mar 2015 10:17:56 +0100
changeset 130c8d81bfa5fff
parent 129 9d5867ce966a
child 131 9262041d1320
Trying yet another function to bring to foreground but it's broken too.
Server/MainForm.Hid.cs
     1.1 --- a/Server/MainForm.Hid.cs	Wed Mar 18 21:47:06 2015 +0100
     1.2 +++ b/Server/MainForm.Hid.cs	Thu Mar 19 10:17:56 2015 +0100
     1.3 @@ -33,6 +33,8 @@
     1.4  		[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
     1.5  		public static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fAttach);
     1.6  
     1.7 +		[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SwitchToThisWindow")]
     1.8 +		public static extern void SwitchToThisWindow([System.Runtime.InteropServices.InAttribute()] System.IntPtr hwnd, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fUnknown);
     1.9  		//
    1.10  		public delegate void OnHidEventDelegate(object aSender, Hid.Event aHidEvent);
    1.11  
    1.12 @@ -154,7 +156,8 @@
    1.13  					}
    1.14  					else
    1.15  					{
    1.16 -						ForceForegroundWindow(existingProcesses[0].MainWindowHandle);
    1.17 +						//ForceForegroundWindow(existingProcesses[0].MainWindowHandle);
    1.18 +						SwitchToThisWindow(existingProcesses[0].MainWindowHandle, true);
    1.19  					}
    1.20  				}
    1.21  			}