//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OpenIdOfflineProvider {
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
///
/// P/Invoke methods and wrappers.
///
internal static class NativeMethods {
///
/// Gets the HWND of the current foreground window on the system.
///
/// A handle to the foreground window.
[DllImport("user32.dll")]
internal static extern IntPtr GetForegroundWindow();
///
/// Sets the foreground window of the system.
///
/// The HWND of the window to set as active.
/// A value indicating whether the foreground window was actually changed.
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetForegroundWindow(IntPtr hWnd);
///
/// Sets the foreground window of the system.
///
/// The window to bring to the foreground.
///
/// A value indicating whether the foreground window was actually changed.
///
internal static bool SetForegroundWindow(Window window) {
return SetForegroundWindow(new WindowInteropHelper(window).Handle);
}
///
/// Sets the active window of the process.
///
/// The window to bring to the foreground.
internal static void SetActiveWindow(Window window) {
SetActiveWindow(new WindowInteropHelper(window).Handle);
}
///
/// Sets the active window of the process.
///
/// The HWND of the window to set as active.
/// The window that was previously active?
[DllImport("user32.dll")]
private static extern IntPtr SetActiveWindow(IntPtr hWnd);
}
}