Bring another processes Window to foreground when it has ShowInTaskbar = false

Well, code is here. Even if the ShowInTaskBar is false, you should be able to bring it to the front.

    [DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
    public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);

    [DllImport("USER32.DLL")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    public static void bringToFront(string title) {
        // Get a handle to the Calculator application.
        IntPtr handle = FindWindow(null, title);

        // Verify that Calculator is a running process.
        if (handle == IntPtr.Zero) {
            return;
        }

        // Make Calculator the foreground application
        SetForegroundWindow(handle);
    }

Note: you should FindWindow using the form’s class and not by name as the splash screen forms sometimes do not have titles or even the controlbox. Use Spy++ to dig deeper.

Use FindWindow on splash. I think this is what you want to do – bring the splash screen in front while loading of the main form.

Leave a Comment