GlobalAccessSoftware icon

Win32.API SafeNativeCode Class

GlobalAccessSoftware | PRO | 05/26/18 08:38:10 AM UTC | 0 ⭐ | 605 👁️ | Never ⏰ | []
C# |

870 B

|

None

|

0 👍

/

0 👎

#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

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎