Best way to hide a window from the Alt-Tab program

2019-01-02 17:45发布

I've been a .NET developer for several years now and this is still one of those things I don't know how to do properly. It's easy to hide a window from the taskbar via a property in both Windows Forms and WPF, but as far as I can tell, this doesn't guarantee (or necessarily even affect) it being hidden from the Alt+↹Tab dialog. I've seen invisible windows show up in Alt+↹Tab, and I'm just wondering what is the best way to guarantee a window will never appear (visible or not) in the Alt+↹Tab dialog.

Update: Please see my posted solution below. I'm not allowed to mark my own answers as the solution, but so far it's the only one that works.

Update 2: There's now a proper solution by Franci Penov that looks pretty good, but haven't tried it out myself. Involves some Win32, but avoids the lame creation of off-screen windows.

13条回答
步步皆殇っ
2楼-- · 2019-01-02 18:15

Why so complex? Try this:

me.FormBorderStyle = FormBorderStyle.SizableToolWindow
me.ShowInTaskbar = false

Idea taken from here:http://www.csharp411.com/hide-form-from-alttab/

查看更多
登录 后发表回答