Is it possible to hide winform in TaskManager application tab?
Asked Answered
G

2

9

I'm writing a transparent WinForms app and I want to hide the app from showing in Task Manager's applications tab. I'm OK with the fact that it will show in Processes (in fact it should). If I set:

this.ShowInTaskbar = false;

it only hides from taskbar.

Full code i have i have a timer made from labels

        public Form1()
    {
        InitializeComponent();
        this.BackColor = Color.LimeGreen;
        this.TransparencyKey = Color.LimeGreen;
        Timer time = new Timer();
        time.Interval = 1000;
        time.Tick += new EventHandler(time_Tick);
        time.Start();
        this.ShowInTaskbar = false;


    }

    void time_Tick(object sender, EventArgs e)
    {
        label1_hour.Text = DateTime.Now.Hour.ToString() ;
        label_minute.Text = DateTime.Now.Minute.ToString();
        label_second.Text = DateTime.Now.Second.ToString();
    }
Gauss answered 10/2, 2012 at 17:44 Comment(1)
yes thre is a way.. can you show the full code where you have the this.ShowInTaskBar = false;Bimetallism
B
33

Try something like this

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        this.FormBorderStyle = FormBorderStyle.None;
        this.ShowInTaskbar = false;
    }
    protected override CreateParams CreateParams {
        get {
            var cp = base.CreateParams;
            cp.ExStyle |= 0x80;  // Turn on WS_EX_TOOLWINDOW
            return cp;
        }
    }
}
Bimetallism answered 10/2, 2012 at 17:51 Comment(5)
Is this going to hide it from the Task Manager?Oleomargarine
Go ahead and try it.. it should hide from the TaskManager.. The CreateParams overrides the expected result that you are looking for..Bimetallism
Gets or sets a bitwise combination of extended window style values. The ExStyle property supports extended appearance and initial state values to apply to the control. For more information about creating control parameters, see the CreateWindow and CreateWindowEx functions and the CREATESTRUCT structure documentation in the Windows Platform SDK reference located in the MSDN Library. Referenced from MSDN - msdn.microsoft.com/en-us/library/…Bimetallism
Krishna how can this not be working for you when everyone has tested this and John as well as awayoftarget state the opposite..?Bimetallism
I have created a sample project from sharpdevelop ide, when I'm running the project from IDE the process is invisible, but when I'm executing the exe file that is built, it shows a small form without borders on the screen and also a process in task manager.Jolda
T
0

Simply setting the form property FormBorderStyle to FixedToolWindow worked for me. On Win 10 it removes it from "Apps" in Task Manager and puts it in "Background processes"...which the OP specified (and was what I wanted also.)

In addition, it removes the form from showing in "Windows Key + Tab" listing of windows...which is what I wanted as well.

Teocalli answered 8/12, 2017 at 18:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.