Created
June 8, 2010 16:37
-
-
Save glebd/430281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment