Default
Google

How can I create MDI applications?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

Many programs such as Microsoft Word ® can open multiple documents at the same time. In this case, each document has its own window. How can I create an application with this capability?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Set the FormStyle property of your main form to fsMDIForm.
 
 3.
  Add a second form using File | New Form. Set its FormStyle
      to fsMDIChild.
 
 4.
  Add a menu and insert the item File and the subitem New.
 
 5.
  Edit the OnClick event of New:
 
void __fastcall TForm1::New1Click(TObject *Sender)
{
    TForm2 *child;
    // Create the child window
    child = new TForm2(Application);
    // Change the caption of the child window
    child->Caption = "Child Form " + (String)MDIChildCount;
}
 
 6.
  Add the header file of the second form using File | Include
      Unit Hdr...
 
MDI (Multiple Document Interface) applications are very easy to create. Probably the simplest way is to click on File | New... and from the Projects tab to select MDI Application. But even if you want to build your application yourself, you can still do it as easily as the previous steps. All you need to do is change the FormStyle.

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange