Saturday, June 4, 2011

Hide Form from Alt+Tab

Hide Form from Start Bar
To prevent a form from appearing in the Windows Start bar, add this statement to the form’s constructor:

this.ShowInTaskbar = false;Hide Tool Window from Alt+Tab
To prevent a form from appearing in the list of windows shown when the user presses Alt+Tab, you can designate the form to be a tool window. Note that you can use SizableToolWindow or FixedToolWindow, and ShowInTaskbar must be set to false:

this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.ShowInTaskbar = false;



Hide Borderless Form from Alt+Tab
However, if you want the form to be borderless, then you need to add the following statements to the form’s constructor:

this.FormBorderStyle = FormBorderStyle.None;
this.ShowInTaskbar = false;AND you must add the following method to your derived Form class:

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

No comments:

Post a Comment