winform去掉最小化后左下角窗口,托盘处理

winform去掉最小化后左下角窗口,托盘处理_第1张图片
去掉如图的窗口;

    public partial class FormZpenSample : Form
    {

        public FormZpenSample()
        {
            InitializeComponent();

            #region 托盘处理
      
            //隐藏ui 
            this.WindowState = FormWindowState.Minimized;

            //隐藏任务栏区图标
            this.ShowInTaskbar = false;

            //不显示
            this.Hide();

            //图标显示在托盘区
            notifyIcon1.Visible = true;

            //双击展示
            notifyIcon1.DoubleClick += (sender, evegs) =>
            {
                this.Show();
            };

            //去掉最小化后左下角窗口
            this.Resize += (sender, even) =>
            {
                var formCurrent = sender as Form;
                if (formCurrent != null && formCurrent.WindowState == FormWindowState.Minimized)
                {
                    formCurrent.Hide();
                }
                else if (formCurrent != null && formCurrent.WindowState == FormWindowState.Normal)
                {
                    formCurrent.Show();
                }
            };

            #endregion
 
        }
}

你可能感兴趣的:(Winform,开发语言,c#)