diff options
Diffstat (limited to 'samples/OpenIdOfflineProvider/NativeMethods.cs')
-rw-r--r-- | samples/OpenIdOfflineProvider/NativeMethods.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/samples/OpenIdOfflineProvider/NativeMethods.cs b/samples/OpenIdOfflineProvider/NativeMethods.cs new file mode 100644 index 0000000..ec12819 --- /dev/null +++ b/samples/OpenIdOfflineProvider/NativeMethods.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="NativeMethods.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.OpenIdOfflineProvider { + using System; + using System.Runtime.InteropServices; + using System.Windows; + using System.Windows.Interop; + + internal static class NativeMethods { + /// <summary> + /// Gets the HWND of the current foreground window on the system. + /// </summary> + /// <returns>A handle to the foreground window.</returns> + [DllImport("user32.dll")] + internal static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern IntPtr SetActiveWindow(IntPtr hWnd); + + internal static bool SetForegroundWindow(Window window) { + return SetForegroundWindow(new WindowInteropHelper(window).Handle); + } + + internal static void SetActiveWindow(Window window) { + SetActiveWindow(new WindowInteropHelper(window).Handle); + } + } +} |