9

我正在编写一个透明的 WinForms 应用程序,我想隐藏该应用程序,使其不显示在任务管理器的应用程序选项卡中。我对它会在流程中显示的事实感到满意(事实上它应该)。如果我设置:

this.ShowInTaskbar = false;

它只隐藏在任务栏中。

我有完整的代码我有一个由标签制成的计时器

        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();
    }
4

2 回答 2

31

尝试这样的事情

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;
        }
    }
}
于 2012-02-10T17:51:55.863 回答
0

只需将表单属性 FormBorderStyle 设置为 FixedToolWindow 对我有用。在 Win 10 上,它将它从任务管理器的“应用程序”中删除,并将其放入“后台进程”中……这是 OP 指定的(也是我想要的。)

此外,它从窗口的“Windows Key + Tab”列表中删除了表单......这也是我想要的。

于 2017-12-08T18:11:41.777 回答