简体   繁体   English

C# - 从代码中隐藏在切换窗口(alt + tab)上创建的表单

[英]C# - Hide created form on switch window (alt + tab) from code

I have a form that can create another form like this. 我有一个表单可以创建这样的另一个表单。

private void AEGISBot(String option) {
        if (AEGIS == null) {
            AEGIS = new Form();
            AEGIS.ShowInTaskbar = false;
            AEGIS.TopMost = true;
            AEGIS.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            AEGIS.Size = new Size(396, 191);
            //AEGIS.Size = new Size(720, 720);
            AEGIS.StartPosition = FormStartPosition.CenterScreen;
            AEGIS.BackColor = Color.LightBlue;
            AEGIS.TransparencyKey = AEGIS.BackColor;
            Label AEGISLabel = new Label();
            AEGISLabel.Location = new Point(0, 0);
            AEGISLabel.Size = new Size(AEGIS.Size.Width, AEGIS.Size.Height);
            AEGISLabel.TextAlign = ContentAlignment.MiddleCenter;
            AEGISLabel.Text = "AEGIS";
            AEGISLabel.Font = new Font("Agency FB", 120, FontStyle.Bold);
            AEGISLabel.ForeColor = System.Drawing.Color.Navy;
            AEGIS.Controls.Add(AEGISLabel);
        }

        if (option == "show"){
            AEGIS.Show();
        }
    }

But how to hide it from alt tab. 但是如何从alt选项卡中隐藏它。 I tried to add code like this. 我试着添加这样的代码。

protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x80;
            return cp;
        }
    }

My main form was successfully hidden from alt tab. 我的主要表单已成功隐藏在alt选项卡中。 But how to use it to created form ?? 但是如何使用它来创建表单?

Thank you 谢谢

-Edit -编辑

I am using Windows Form Application. 我正在使用Windows窗体应用程序。 With some form setting 使用一些表单设置

this.ShowInTaskbar = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.ShowIcon = false;
this.WindowState = FormWindowState.Minimized;

尝试使用AEGIS.ShowDialog()而不是AEGIS.Show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM