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

This commit is contained in:
2019-08-23 19:16:02 +01:00
parent 5476331073
commit 036fd48bcf
3 changed files with 109 additions and 10 deletions
+2 -10
View File
@@ -2,6 +2,7 @@ using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace ASCOM.Meade.net
@@ -73,18 +74,9 @@ namespace ASCOM.Meade.net
return profileProperties;
}
[DllImport("user32.dll")]
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)
{
Process currentProcess = Process.GetCurrentProcess();
AllowSetForegroundWindow(currentProcess.Id);
SetForegroundWindow(Handle);
Win32Utilities.BringWindowToFront(Handle);
Activate();
}