Another attempt to sort out the dialog appearing behind other windows.

This commit is contained in:
2019-08-23 18:57:48 +01:00
parent c6cab848f9
commit 5476331073
+7
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
@@ -75,8 +76,14 @@ namespace ASCOM.Meade.net
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd); private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool AllowSetForegroundWindow(int dwProcessId);
private void SetupDialogForm_Shown(object sender, EventArgs e) private void SetupDialogForm_Shown(object sender, EventArgs e)
{ {
Process currentProcess = Process.GetCurrentProcess();
AllowSetForegroundWindow(currentProcess.Id);
SetForegroundWindow(Handle); SetForegroundWindow(Handle);
Activate(); Activate();
} }