1

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. 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. But how to use it to created form ??

Thank you

-Edit

I am using Windows Form Application. With some form setting

this.ShowInTaskbar = false;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.ShowIcon = false;
this.WindowState = FormWindowState.Minimized;
DovahkiiND
  • 17
  • 4
  • Assuming you got that code from [here](https://stackoverflow.com/questions/357076/best-way-to-hide-a-window-from-the-alt-tab-program-switcher?rq=1), I'd suggest you give a bit more information on your main form. Have you tried `AEGIS.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow` ? Also, is your main form also set to `ShowInTaskbar = false;` ? – Mat Jun 20 '17 at 23:30
  • Yes @Mat, already do that. I set my Main Form Border Style to None and ShowInTaskbar equal to false. Also in AEGIS form. – DovahkiiND Jun 20 '17 at 23:46
  • Hmm, [this](https://social.msdn.microsoft.com/Forums/vstudio/en-US/8e3a788e-1e14-4751-a756-2d68358f898b/hide-icon-in-alttab?forum=wpf) (see accepted answer there) is the only other fairly simply option I found. If that doesn't do anything, I'm afraid we might need more info (how is your main form created, what's its settings, etc). – Mat Jun 20 '17 at 23:57
  • Added some info to question – DovahkiiND Jun 21 '17 at 00:16
  • To help you, we have to know in which class `CreateParams` property override is defined and also the style associated to `0x80`. Also you say that your main form is hidden from Alt-Tab but not the created form... which seems odd. It should be easier to hide extra windows than the main one. **By the way, you should never use `TopMost` flag on a form.** If you want to provide such option, it should be optional and not selected by default. – Phil1970 Jun 21 '17 at 01:06

1 Answers1

0

Try using AEGIS.ShowDialog() instead of AEGIS.Show().

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
Dan
  • 34
  • 2