summaryrefslogtreecommitdiffstats
path: root/src/OpenID/OpenIdOfflineProvider/NativeMethods.cs
diff options
context:
space:
mode:
authorDavid Christiansen <coding@davedoes.net>2012-06-30 16:06:46 -0700
committerDavid Christiansen <coding@davedoes.net>2012-06-30 16:06:46 -0700
commit06401bb049dc29cf4446eb61a4a72317a644ce54 (patch)
tree7c475929350b31b4b848a1faa57bd0d7cbbf512c /src/OpenID/OpenIdOfflineProvider/NativeMethods.cs
parent02ce959db12fec57e846e5ebfa662cd0327ce69c (diff)
parent3286c37f3a967e7d142534df84604a66be9d176c (diff)
downloadDotNetOpenAuth.Samples-06401bb049dc29cf4446eb61a4a72317a644ce54.zip
DotNetOpenAuth.Samples-06401bb049dc29cf4446eb61a4a72317a644ce54.tar.gz
DotNetOpenAuth.Samples-06401bb049dc29cf4446eb61a4a72317a644ce54.tar.bz2
Merge pull request #1 from DavidChristiansen/master
Kachow!
Diffstat (limited to 'src/OpenID/OpenIdOfflineProvider/NativeMethods.cs')
-rw-r--r--src/OpenID/OpenIdOfflineProvider/NativeMethods.cs60
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);
+ }
+}