FrmScreenAutomation: Only top level while running.

This commit is contained in:
2019-11-05 17:32:14 +01:00
parent 2f8f4492ea
commit 4da5466de9
2 changed files with 12 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ namespace VAR.ScreenAutomation.Code
public class WindowHandling
{
private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
@@ -16,9 +17,16 @@ namespace VAR.ScreenAutomation.Code
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
public static void WindowSetTopLevel(Form form)
public static void WindowSetTopLevel(Form form, bool top = true)
{
SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
if (top)
{
SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}
else
{
SetWindowPos(form.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
}
}
public static bool ApplicationIsActivated()