Reputation: 8721
I'm trying to find a way to hide the main form of my app from Alt-Tab list after minimizing it. So far I found that setting form style to SizableToolWindow
does the trick, but this seems like an improper solution.
I have two winform apps. One of them is supposed to only have tray icon visible, but it still has the main form. Alt-Tab visibility problem is resolved there by doing this.Hide()
in Form_Shown
method. The other app does not have Form_Shown
, but it has Form1_SizeChanged
method with code:
this.Hide();
this.ShowInTaskbar = false;
…and for some reason it does not result in the same as the first app. I could only hide it from Alt-Tab list by also setting the main form's style to SizableToolWindow
. While it's working, I'd like to know why the supposedly proper approach does not.
Upvotes: 1
Views: 339
Reputation: 8721
Putting this.ShowInTaskbar = false
before this.Hide()
should hide the form from Alt-Tab list. Apparently, you have to set the visibility option before hiding the form, or it will not hide the window from Alt-Tab. With this there is no need to set the form style to ToolWindow
. As for the "why", I have no idea.
Upvotes: 1