summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/OpenIdOfflineProvider/CheckIdWindow.xaml2
-rw-r--r--samples/OpenIdOfflineProvider/MainWindow.xaml.cs5
-rw-r--r--samples/OpenIdOfflineProvider/NativeMethods.cs36
-rw-r--r--samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj1
4 files changed, 43 insertions, 1 deletions
diff --git a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml
index 1211976..29e5126 100644
--- a/samples/OpenIdOfflineProvider/CheckIdWindow.xaml
+++ b/samples/OpenIdOfflineProvider/CheckIdWindow.xaml
@@ -1,7 +1,7 @@
<Window x:Class="DotNetOpenAuth.OpenIdOfflineProvider.CheckIdWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="Authentication request" Height="345" Width="379">
+ Title="Authentication request" Height="345" Width="379" ShowInTaskbar="False">
<DockPanel Margin="12">
<TextBlock DockPanel.Dock="Top" TextWrapping="Wrap">An authentication request has been received. How do you want to proceed?</TextBlock>
<Expander DockPanel.Dock="Top" Header="View request details" IsExpanded="True">
diff --git a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs
index 56ce7b6..a0ee56e 100644
--- a/samples/OpenIdOfflineProvider/MainWindow.xaml.cs
+++ b/samples/OpenIdOfflineProvider/MainWindow.xaml.cs
@@ -124,7 +124,12 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider {
authRequest.IsAuthenticated = false;
break;
case 2:
+ IntPtr oldForegroundWindow = NativeMethods.GetForegroundWindow();
+ bool stoleFocus = NativeMethods.SetForegroundWindow(this);
CheckIdWindow.ProcessAuthentication(this.hostedProvider, authRequest);
+ if (stoleFocus) {
+ NativeMethods.SetForegroundWindow(oldForegroundWindow);
+ }
break;
}
}
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);
+ }
+ }
+}
diff --git a/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj b/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj
index 5b59b7d..1bb2367 100644
--- a/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj
+++ b/samples/OpenIdOfflineProvider/OpenIdOfflineProvider.csproj
@@ -125,6 +125,7 @@
</Compile>
<Compile Include="HostedProvider.cs" />
<Compile Include="HttpHost.cs" />
+ <Compile Include="NativeMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>