Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Hiding the form from alt-tab menu

4.80/5 (10 votes)
19 Dec 2010CPOL 22.3K  
Hiding the form from alt-tab menu
This is a UI tweak for hiding the form from alt-tab menu.

C#
protected override CreateParams CreateParams
{
   get
   {
      CreateParams cp = base.CreateParams;
      cp.ExStyle |= 0x80;
      return cp;
   }
}


Edit:
In order to make it work, you have to use Me.ShowInTaskbar = False

Description:

WS_EX_TOOLWINDOW bit is turned on by OR-ing ExStyle with 0x80.

The following always works,
C#
Me.FormBorderStyle = FormBorderStyle.SizableToolWindow;
Me.ShowInTaskbar = False;


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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)