I have a program that consists of 2 Forms in C++.NET.

When I open Form1 that is my "StartForm", this Form comes up in the TaskBar
as all applications and Folders etc on the computer.

So when I open Form2 from Form1. Both these Forms will appear in the TaskBar.
What I wonder how it could be possible is when you open this Form2, I only want the
Form1 to still appear in the TaskBar, not both of them.
How is this possible to do. I have heard or red something about childforms etc but are not
sure if this is a solution or how they work.

I have red a example. It says something about writing something like this:
Form1::Form2. (Form2 is not a member of Form1 here for ex) Also:
MyForm2->Form1. (Form1 is not a member of MyForm2).

I have put: (IsMdiContainer = true; on Form1)
Though I dont know if this is the right approach or if I am on the right track.

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) 
 {
 Form1::Form2 *MyForm2 = new Form1::Form2;
 MyForm2->Form1 = this;
 MyForm2->Show();
 }

Have you tried ..
to show the sub-form from the main form (which has to be a MDIContainer)

// remove the taskbar style from the main form
this->ShowInTaskbar = false;
SubForm.MdiParent = this;
Subform.Show();

And when the sub-form closes, use ParentForm ...

// Restore the taskbar style of the main form
ParentForm->ShowInTaskbar = true;
Close();

Yes, this works with a little exeption though. I have put the code like this on Form2.

So when I open Form2 from Form1 the first time, Form2 shows and immediately closes ?
When I open Form2 the second time it shows and stays and it works that only Form1 shows in the TaskBar wich is great.
I wonder though why the Form2 opens and closes the first time I open it ?

private: System::Void Form2_Load(System::Object^  sender, System::EventArgs^  e) 
{
	
 this->ShowInTaskbar = false;
 Form2::Show();

It worked when I did put it under InitializeComponent();
Now it opens and stays normally. Thank you for help !

public:
Form3(void)
{
InitializeComponent();
		
this->ShowInTaskbar = false;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.