Skip to content

Instantly share code, notes, and snippets.

@glebd
Created April 20, 2010 10:21
Show Gist options
  • Save glebd/372271 to your computer and use it in GitHub Desktop.
Save glebd/372271 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace Utility
{
public static class UserHelper
{
[DllImport("user32.dll")]
public static extern IntPtr GetActiveWindow();
public static bool ShowDialog(Window dialog, Window owner)
{
new WindowInteropHelper(dialog)
{
Owner = owner != null
? new WindowInteropHelper(owner).Handle
: GetActiveWindow()
};
var dialogResult = dialog.ShowDialog();
return dialogResult.HasValue ? dialogResult.Value : false;
}
}
}
@glebd
Copy link
Author

glebd commented Apr 20, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment