Trying to fix on bring to foreground mess.
authorStephaneLenclud
Wed, 18 Mar 2015 20:38:59 +0100
changeset 1282e0571e50ab3
parent 127 75addfa85201
child 129 9d5867ce966a
Trying to fix on bring to foreground mess.
Server/MainForm.Hid.cs
Server/SharpDisplayManager.csproj
     1.1 --- a/Server/MainForm.Hid.cs	Wed Mar 18 20:10:38 2015 +0100
     1.2 +++ b/Server/MainForm.Hid.cs	Wed Mar 18 20:38:59 2015 +0100
     1.3 @@ -20,6 +20,15 @@
     1.4  		[DllImport("USER32.DLL")]
     1.5  		public static extern bool SetForegroundWindow(IntPtr hWnd);
     1.6  
     1.7 +		[DllImport("USER32.DLL")]
     1.8 +		public static extern bool BringWindowToTop(IntPtr hWnd);
     1.9 +
    1.10 +		[DllImport("USER32.DLL")]
    1.11 +		public static extern bool IsIconic(IntPtr hWnd);
    1.12 +
    1.13 +		[DllImport("USER32.DLL")]
    1.14 +		public static extern bool OpenIcon(IntPtr hWnd);
    1.15 +
    1.16  
    1.17  		public delegate void OnHidEventDelegate(object aSender, Hid.Event aHidEvent);
    1.18  
    1.19 @@ -134,6 +143,13 @@
    1.20  					}
    1.21  					else
    1.22  					{
    1.23 +						BringWindowToTop(existingProcesses[0].MainWindowHandle);
    1.24 +						SetForegroundWindow(existingProcesses[0].MainWindowHandle);
    1.25 +						if (IsIconic(existingProcesses[0].MainWindowHandle))
    1.26 +						{
    1.27 +							OpenIcon(existingProcesses[0].MainWindowHandle);
    1.28 +						}
    1.29 +						BringWindowToTop(existingProcesses[0].MainWindowHandle);
    1.30  						SetForegroundWindow(existingProcesses[0].MainWindowHandle);
    1.31  					}			
    1.32  				}
     2.1 --- a/Server/SharpDisplayManager.csproj	Wed Mar 18 20:10:38 2015 +0100
     2.2 +++ b/Server/SharpDisplayManager.csproj	Wed Mar 18 20:38:59 2015 +0100
     2.3 @@ -31,7 +31,7 @@
     2.4      <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     2.5      <WebPage>index.htm</WebPage>
     2.6      <OpenBrowserOnPublish>false</OpenBrowserOnPublish>
     2.7 -    <ApplicationRevision>1</ApplicationRevision>
     2.8 +    <ApplicationRevision>3</ApplicationRevision>
     2.9      <ApplicationVersion>0.3.2.%2a</ApplicationVersion>
    2.10      <UseApplicationTrust>false</UseApplicationTrust>
    2.11      <CreateDesktopShortcut>true</CreateDesktopShortcut>