{"id":560,"date":"2011-01-06T20:49:49","date_gmt":"2011-01-06T20:49:49","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=560"},"modified":"2022-02-17T06:24:04","modified_gmt":"2022-02-17T06:24:04","slug":"child-forms-multiple-document-interface","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/forms\/child-forms-multiple-document-interface","title":{"rendered":"Child Forms \/ Multiple Document Interface"},"content":{"rendered":"<p>Int Note: Kin Lib uses child forms<\/p>\n<p>Applications that have a main window which contain one or more child windows are called Multiple Document Interface (MDI)<\/p>\n<p>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.<\/p>\n<h4>To create a child form<\/h4>\n<p>Create a new form as normal<\/p>\n<pre><code>\r\n\tCellsStatusForm1-&gt;MdiParent = this;\r\n\tCellsStatusForm1-&gt;Show();\r\n<\/code><\/pre>\n<p>Then see page 163 of Visual Studio 2008 for dummies&#8230;<\/p>\n<h4>Detecting When Child Forms Close<\/h4>\n<h5>When you create and open the child form<\/h5>\n<pre><code>\r\n\tMyChildForm = gcnew frmBarGraphs();\r\n\tMyChildForm-&gt;FormClosed += gcnew FormClosedEventHandler(this, &amp;frmMain::MyChildForm_FormClosed);\r\n\tMyChildForm-&gt;MdiParent = this;\r\n\tMyChildForm-&gt;Show();\r\n<\/code><\/pre>\n<h5>And the callback function that will be called<\/h5>\n<pre><code>\r\n\tprivate: void MyChildForm_FormClosed(System::Object^ sender, System::Windows::Forms::FormClosedEventArgs^ e)\r\n\t{\r\n\t\t\/\/Do this if you want to be able to get some values back from the form before it closes:\r\n\t\tfrmMyChildForm ^ClosingForm = dynamic_cast&lt;frmMyChildForm^&gt;(sender);\r\n\r\n\t\tif (e-&gt;CloseReason == System::Windows::Forms::CloseReason::UserClosing)\r\n\t\t{\r\n\t\t\t\/\/Only do if user has closed child form\r\n\t\t\t\/\/(we don't want this if form is closing because the application is closing)\r\n\t\t\tSomethingIWantToStore = ClosingForm-&gt;SomeValueOfMine;\r\n\r\n\t\t\t\/\/Update our menu bar or whatever to reflect the form being closed\r\n\r\n\t\t}\r\n       }\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-560","post","type-post","status-publish","format-standard","hentry","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=560"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/560\/revisions"}],"predecessor-version":[{"id":1053,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/560\/revisions\/1053"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}