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

时间:2017-06-20 23:01:02

标签: c# forms winforms visual-studio

我有一个可以创建这样的另一种形式的表单。

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

但是如何从alt选项卡中隐藏它。我试着添加这样的代码。

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

我的主要表单已成功隐藏在alt标签中。但是如何使用它来创建表单?

谢谢

- 编辑

我正在使用Windows Form Application。使用一些表单设置

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

1 个答案:

答案 0 :(得分:0)

尝试使用AEGIS.ShowDialog()代替AEGIS.Show()