#region SafeNativeMethods Static Class
// Special little class of cool tricks.
[SuppressUnmanagedCodeSecurity]
public static class SafeNativeMethods
{ // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[DllImport("user32.dll")]
private static extern bool
SetForegroundWindow(
IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool
ShowWindowAsync(
IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern bool
IsIconic(
IntPtr hWnd);
// My Custom Class and Public Method
// Brings called Window to front in
// Windows from another App or 2nd instance
// of your App to communicate to the 1st.
public static void B2F(IntPtr hWnd)
{
if (IsIconic(hWnd))
ShowWindowAsync(hWnd, 9);
SetForegroundWindow(hWnd);
}
}
Comments
0 B
|👍
/👎