Int Note: Kin Lib uses child forms

Applications that have a main window which contain one or more child windows are called Multiple Document Interface (MDI)

For the parent form (for instance the form created when creating a new project) set the IsMdiContainer property to true. Add a menu strip to the form and create menu items to allow the user to open new child forms.

To create a child form

Create a new form as normal


	CellsStatusForm1->MdiParent = this;
	CellsStatusForm1->Show();

Then see page 163 of Visual Studio 2008 for dummies…

Detecting When Child Forms Close

When you create and open the child form

	MyChildForm = gcnew frmBarGraphs();
	MyChildForm->FormClosed += gcnew FormClosedEventHandler(this, &frmMain::MyChildForm_FormClosed);
	MyChildForm->MdiParent = this;
	MyChildForm->Show();
And the callback function that will be called

	private: void MyChildForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)
	{
		//Do this if you want to be able to get some values back from the form before it closes:
		frmMyChildForm ^ClosingForm = dynamic_cast<frmMyChildForm^>(sender);

		if (e->CloseReason == System::Windows::Forms::CloseReason::UserClosing)
		{
			//Only do if user has closed child form
			//(we don't want this if form is closing because the application is closing)
			SomethingIWantToStore = ClosingForm->SomeValueOfMine;

			//Update our menu bar or whatever to reflect the form being closed

		}
       }
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.