Hide a borderless window from the ALT + TAB menu

I am developing a Tray application with a Borderless Form running in the background. if the user wants to perform different operations, they can open the context menu by right-clicking on the tray icon (NotifyIcon).

so my requirements are:

1.Application always starts in minimized mode and the tray will be displayed.
2. The application should not appear on the taskbar. 3. Application should not be visible from the ALT + TAB menu.

I followed the above two requirements, but when I try to hide the application from the ALT + Tab menu, it works (not visible from ALT + TAB), but creates a small window with the application title in the left corner above the taskbar as shown below: enter image description here

I want to remove this little window.

Here is my code:

    public Form1()
    {
        InitializeComponent();
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        HideThisForm();
    }

    protected override CreateParams CreateParams
    {
        get
        {
            // Turn on WS_EX_TOOLWINDOW style bit
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x80;
            return cp;
        }
    }

    private void HideThisForm()
    {

        this.ShowInTaskbar = false;
        this.WindowState = FormWindowState.Minimized;
        this.Hide();

        notifyApp.Visible = true;
        notifyApp.ShowBalloonTip(2000, "BackgroundApp", 
                    "This APP is running @ Background", ToolTipIcon.Info);
    }

      

PS: I have looked at several similar posts on StackOverflow, but none of them faced a similar problem.

+3


source to share


2 answers


I did this before using this.Opacity=0;

. Kind of hacky, but with WinForms this might be the only way.



+2


source


if you have a borderless form, i.e. FormBorderStyle.None then ShowInTaskbar = False doesn't work. So, we have to set WS_EX_TOOLWINDOW to true in addition to Me.ShowInTaskbar = False.

This is not from me, but from this: http://www.codeproject.com/Tips/135076/Hiding-the-form-from-alt-tab-menu



You can always try to set the borderstyle to whatever you want when the form becomes visible (and rotate it back when you lose focus)

0


source







All Articles