diff options
author | David Christiansen <coding@davedoes.net> | 2012-03-15 22:10:55 +0000 |
---|---|---|
committer | David Christiansen <coding@davedoes.net> | 2012-03-15 22:10:55 +0000 |
commit | a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f (patch) | |
tree | a3057157fa3287e0c0c4cc49be1854f9aa63d321 /src/OpenID/OpenIdOfflineProvider/NativeMethods.cs | |
parent | 02ce959db12fec57e846e5ebfa662cd0327ce69c (diff) | |
download | DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.zip DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.gz DotNetOpenAuth.Samples-a5bfa2bb8a614b1932ec8b7bbc6a0cc6bca3051f.tar.bz2 |
W.I.P.
* Initial migration and reference to DNOA Nuget packages (From teamcity.dotnetopenauth.net)
* Awaiting fix to DotNetOpenAuth.OpenIdOAuth.nuspec in order to complete migration.
Diffstat (limited to 'src/OpenID/OpenIdOfflineProvider/NativeMethods.cs')
-rw-r--r-- | src/OpenID/OpenIdOfflineProvider/NativeMethods.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/OpenID/OpenIdOfflineProvider/NativeMethods.cs b/src/OpenID/OpenIdOfflineProvider/NativeMethods.cs new file mode 100644 index 0000000..5e69f33 --- /dev/null +++ b/src/OpenID/OpenIdOfflineProvider/NativeMethods.cs @@ -0,0 +1,60 @@ +//----------------------------------------------------------------------- +// <copyright file="NativeMethods.cs" company="Outercurve Foundation"> +// Copyright (c) Outercurve Foundation. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.OpenIdOfflineProvider { + using System; + using System.Runtime.InteropServices; + using System.Windows; + using System.Windows.Interop; + + /// <summary> + /// P/Invoke methods and wrappers. + /// </summary> + 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(); + + /// <summary> + /// Sets the foreground window of the system. + /// </summary> + /// <param name="hWnd">The HWND of the window to set as active.</param> + /// <returns>A value indicating whether the foreground window was actually changed.</returns> + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + internal static extern bool SetForegroundWindow(IntPtr hWnd); + + /// <summary> + /// Sets the foreground window of the system. + /// </summary> + /// <param name="window">The window to bring to the foreground.</param> + /// <returns> + /// A value indicating whether the foreground window was actually changed. + /// </returns> + internal static bool SetForegroundWindow(Window window) { + return SetForegroundWindow(new WindowInteropHelper(window).Handle); + } + + /// <summary> + /// Sets the active window of the process. + /// </summary> + /// <param name="window">The window to bring to the foreground.</param> + internal static void SetActiveWindow(Window window) { + SetActiveWindow(new WindowInteropHelper(window).Handle); + } + + /// <summary> + /// Sets the active window of the process. + /// </summary> + /// <param name="hWnd">The HWND of the window to set as active.</param> + /// <returns>The window that was previously active?</returns> + [DllImport("user32.dll")] + private static extern IntPtr SetActiveWindow(IntPtr hWnd); + } +} |