我正在编写一个透明的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();
}
试试这样的
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;
}
}
}
只需将表单属性FormBorderStyle设置为FixedToolWindow就可以了。在Win 10上,它会将其从任务管理器的"应用程序"中删除,并将其放入"后台进程"中。。。OP指定的(这也是我想要的)
此外,它还删除了窗体在"Windows键+选项卡"窗口列表中的显示。。。这也是我想要的。