Jun 29
When you show a .NET Form, by default the form will appear in the Windows Start bar and in the list of open windows shown when the user presses 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; } }
.NET, C#, Tips, Windows Forms
Here is your +1 🙂
Thnks for the code for Borderless Forms. I used it for creating custom ContextMenu.
Thank You Very Much .. Good Job Man !!
Thank you.
Vielen Dank 😀
Thank you very much. Its great.
The bordless from alt+tab was really useful. Thank you.
i am running a exe at the time of system startup.the form’s are In-Visible but when i click alt+tab a blank window in visible.how can i ignore that window.please send me the solution through this mail ID.
with Regards,
santosh
Excellent post. Thank you.
Excellent man! It really works. Thanks
Thanks for making idea of borderless form. Excellent work.
It works after program start. But once I have set window state to normal and then back to minimized, the tool appears in the alt+tab-list.
(I have a tool reduced to a notifcation icon which checks for a file periodically and pops up with the file content if it finds one.)
private void toggleVisible(bool mode) {
this.TopMost = mode;
if (mode) {
this.WindowState = FormWindowState.Normal;
} else {
//also called from constructor:
this.WindowState = FormWindowState.Minimized;
this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.ShowInTaskbar = false;
}
}
Thank you very much, the code work’s perfect. I’ve converted it to VB.NET should anyone need it:
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
‘ turn on WS_EX_TOOLWINDOW style bit
cp.ExStyle = cp.ExStyle Or &H80
Return cp
End Get
End Property
Okay, I think I’ve found a definitive solution that simply is not sensitive to what kind of window style the window you are keeping hidden from Alt-Tab has. Just place this in the constructor of your form:
// Keep this program out of the Alt-Tab menu
Form form1 = new Form ( );
form1.FormBorderStyle = FormBorderStyle.FixedToolWindow;
form1.ShowInTaskbar = false;
Owner = form1;
Oops, I forgot that to add the line
ShowInTaskbar = false;
For the form your are hiding.
many many thanks !!!
and for vb.net developer :
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
‘ turn on WS_EX_TOOLWINDOW style bit
cp.ExStyle = cp.ExStyle Or &H80
Return cp
End Get
End Property
bye 🙂
how do you hide the form from the desktop after opening a new form?
+1… Thanks a lot.. SizableToolWindow worked for me.
To get it to work for me I added the Opacity setting as without that, when minimised, in the bottom left-hand corner of your Desktop you could see the top bar of your form.
Form form1 = new Form ( );
form1.FormBorderStyle = FormBorderStyle.FixedToolWindow;
form1.Visible = false;
form1.Opacity = 0;
form1.ShowInTaskbar = false;
Owner = form1;
So on the Minimize event set:
form1.FormBorderStyle = FormBorderStyle.FixedToolWindow;
form1.Visible = false;
form1.Opacity = 0;
form1.ShowInTaskbar = false;
Or no Normalize event set:
form1.FormBorderStyle = FormBorderStyle.FixedSingle;
form1.Visible = true;
form1.Opacity = 100;
form1.ShowInTaskbar = true;
@Alessandro thanks for translating to VB.NET! I was looking for this.
Sweet, just what i was looking for.
You saved me a lot of trouble!
thank you .
thanks!
This solution works great for me! Also found it on CodeProject: http://www.codeproject.com/Tips/135076/Hiding-the-form-from-alt-tab-menu.
please i need to know how i can know the key input to unhidden my form.
Hi
Thanks for you support….
Thanks
Prasad NVM
Hi Everyone. How can I execute this code when button click;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
// turn on WS_EX_TOOLWINDOW style bit
cp.ExStyle |= 0x80;
return cp;
}
}
Exelent!
+1
Thank You Very Much 🙂
Not working on win 8.1