Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 157151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:27:11+00:00 2026-05-11T10:27:11+00:00

I’ve been a .NET developer for several years now and this is still one

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:27:12+00:00Added an answer on May 11, 2026 at 10:27 am

    Update: [Verified and is not working, ignore the edit]

    According to @donovan, modern days WPF supports this natively, through setting ShowInTaskbar="False" and Visibility="Hidden" in the XAML. (I haven’t tested this yet, but nevertheless decided to bump the comment visibility)

    Original answer:

    There are two ways of hiding a window from the task switcher in Win32 API:

    1. to add the WS_EX_TOOLWINDOW extended window style – that’s the right approach.
    2. to make it a child window of another window.

    Unfortunately, WPF does not support as flexible control over the window style as Win32, thus a window with WindowStyle=ToolWindow ends up with the default WS_CAPTION and WS_SYSMENU styles, which causes it to have a caption and a close button. On the other hand, you can remove these two styles by setting WindowStyle=None, however that will not set the WS_EX_TOOLWINDOW extended style and the window will not be hidden from the task switcher.

    To have a WPF window with WindowStyle=None that is also hidden from the task switcher, one can either of two ways:

    • go with the sample code above and make the window a child window of a small hidden tool window
    • modify the window style to also include the WS_EX_TOOLWINDOW extended style.

    I personally prefer the second approach. Then again, I do some advanced stuff like extending the glass in the client area and enabling WPF drawing in the caption anyway, so a little bit of interop is not a big problem.

    Here’s the sample code for the Win32 interop solution approach. First, the XAML part:

    <Window x:Class="WpfApplication1.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Height="300" Width="300"     ShowInTaskbar="False" WindowStyle="None"     Loaded="Window_Loaded" > 

    Nothing too fancy here, we just declare a window with WindowStyle=None and ShowInTaskbar=False. We also add a handler to the Loaded event where we will modify the extended window style. We can’t do that work in the constructor, as there’s no window handle at that point yet. The event handler itself is very simple:

    private void Window_Loaded(object sender, RoutedEventArgs e) {     WindowInteropHelper wndHelper = new WindowInteropHelper(this);      int exStyle = (int)GetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE);      exStyle |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW;     SetWindowLong(wndHelper.Handle, (int)GetWindowLongFields.GWL_EXSTYLE, (IntPtr)exStyle); } 

    And the Win32 interop declarations. I’ve removed all unnecessary styles from the enums, just to keep the sample code here small. Also, unfortunately the SetWindowLongPtr entry point is not found in user32.dll on Windows XP, hence the trick with routing the call through the SetWindowLong instead.

    #region Window styles [Flags] public enum ExtendedWindowStyles {     // ...     WS_EX_TOOLWINDOW = 0x00000080,     // ... }  public enum GetWindowLongFields {     // ...     GWL_EXSTYLE = (-20),     // ... }  [DllImport("user32.dll")] public static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);  public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong) {     int error = 0;     IntPtr result = IntPtr.Zero;     // Win32 SetWindowLong doesn't clear error on success     SetLastError(0);      if (IntPtr.Size == 4)     {         // use SetWindowLong         Int32 tempResult = IntSetWindowLong(hWnd, nIndex, IntPtrToInt32(dwNewLong));         error = Marshal.GetLastWin32Error();         result = new IntPtr(tempResult);     }     else     {         // use SetWindowLongPtr         result = IntSetWindowLongPtr(hWnd, nIndex, dwNewLong);         error = Marshal.GetLastWin32Error();     }      if ((result == IntPtr.Zero) && (error != 0))     {         throw new System.ComponentModel.Win32Exception(error);     }      return result; }  [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", SetLastError = true)] private static extern IntPtr IntSetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);  [DllImport("user32.dll", EntryPoint = "SetWindowLong", SetLastError = true)] private static extern Int32 IntSetWindowLong(IntPtr hWnd, int nIndex, Int32 dwNewLong);  private static int IntPtrToInt32(IntPtr intPtr) {     return unchecked((int)intPtr.ToInt64()); }  [DllImport("kernel32.dll", EntryPoint = "SetLastError")] public static extern void SetLastError(int dwErrorCode); #endregion 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The easy way: Download and use the django debug toolbar.… May 11, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer function closeWindow() { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); alert("This will close the window"); window.open('','_self');… May 11, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer jQuery works great when there's a pattern to follow. For… May 11, 2026 at 8:36 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.