C#: hiding multiple forms from task manager

后端 未结 2 525
眼角桃花
眼角桃花 2021-01-23 22:31

I\'m writing an application which creates a potentially large number of forms to display widgets on the desktop. Every instance of that form shows up in the task manager\'s Appl

2条回答
  •  死守一世寂寞
    2021-01-23 23:29

    Note that the windows also show up in the Alt+Tab bar. You need to change the window style flags by overriding the CreateParams property. Here's a full example:

    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;
            }
        }
    }
    

提交回复
热议问题