none
How to hide window from tasklist (Alt + Tab)

    Question

  • Hi All,

    I wish to remove a window from the alt-tab list. 

    Owned windows are okay, but I don't really want the window to minimise when the main window minimises etc.  Any other solutions?


    Regards
    Gary
    Tuesday, January 13, 2009 7:36 AM

Answers

  • I found the solution at another thread. The solution suggested by Ivan works reliably. (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8e3a788e-1e14-4751-a756-2d68358f898b/)  I re-post his solution here:

    public partial class WindowMain : Window

    {
        public WindowMain()
        {

            //--------------------------------------------------
            // put your initialization logic here...
            //--------------------------------------------------


            Window w = new Window(); // Create helper window
            w.Top = -100; // Location of new window is outside of visible part of screen
            w.Left = -100;
            w.Width = 1; // size of window is enough small to avoid its appearance at the beginning
            w.Height = 1;

            w.WindowStyle = WindowStyle.ToolWindow; // Set window style as ToolWindow to avoid its icon in AltTab 
            w.ShowInTaskbar = false;
            w.Show(); // We need to show window before set is as owner to our main window
            this.Owner = w; // Okey, this will result to disappear icon for main window.
            w.Hide(); // Hide helper window just in case

        }
    }

    Regards
    Gary

    • Marked as answer by Gary lim Wednesday, January 14, 2009 2:09 AM
    Wednesday, January 14, 2009 2:09 AM

All replies

  • I not 100% sure that I understood it correctly, but did you try to use .ShowInTaskbar?
    Tuesday, January 13, 2009 7:49 AM
  • Hi MCMoser,

    Tks for your reply, but this.ShowInTaskbar=false did indeed stop the window appearing in the taskbar, but not in the ALT-TAB menu.


    Regards
    Gary
    Tuesday, January 13, 2009 8:00 AM
  • I believe there is a windows API to hide a window, which will remove it from the alt-tab.
    Compensating what I don't know yet, with what I do know now.
    Tuesday, January 13, 2009 8:06 AM
  • This works:

        public partial class Window1 : Window  
        {  
            public Window1()  
            {  
                InitializeComponent();  
                this.WindowStyle = WindowStyle.ToolWindow;  
                this.ShowInTaskbar = false;  
     
            }  
        }  

    Compensating what I don't know yet, with what I do know now.
    Tuesday, January 13, 2009 8:12 AM
  • Hi SoC,

    Tks for your replied, any workaround for borderless window? (this.WindowStyle = None)


    Regards
    Gary
    Tuesday, January 13, 2009 8:18 AM
  • Not sure in WPF, in good ole c# http://www.csharp411.com/hide-form-from-alttab/

    Perhaps you could simply change the windowstyle just before you want to hide it, and when you want to bring it back, set it back to none.


    Then again, thinking some more here, I think you want the form to be visible the whole time, just not show up in alt-tab, so that previous suggestion wont work.
    Compensating what I don't know yet, with what I do know now.
    Tuesday, January 13, 2009 8:24 AM
  •  

    Em… I am actually looking for WPF way of handling, as I need WPF animation for my window.

     

    Regards

    Gary

    Wednesday, January 14, 2009 1:27 AM
  • I found the solution at another thread. The solution suggested by Ivan works reliably. (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/8e3a788e-1e14-4751-a756-2d68358f898b/)  I re-post his solution here:

    public partial class WindowMain : Window

    {
        public WindowMain()
        {

            //--------------------------------------------------
            // put your initialization logic here...
            //--------------------------------------------------


            Window w = new Window(); // Create helper window
            w.Top = -100; // Location of new window is outside of visible part of screen
            w.Left = -100;
            w.Width = 1; // size of window is enough small to avoid its appearance at the beginning
            w.Height = 1;

            w.WindowStyle = WindowStyle.ToolWindow; // Set window style as ToolWindow to avoid its icon in AltTab 
            w.ShowInTaskbar = false;
            w.Show(); // We need to show window before set is as owner to our main window
            this.Owner = w; // Okey, this will result to disappear icon for main window.
            w.Hide(); // Hide helper window just in case

        }
    }

    Regards
    Gary

    • Marked as answer by Gary lim Wednesday, January 14, 2009 2:09 AM
    Wednesday, January 14, 2009 2:09 AM