Implementing MDI Child forms in Delphi (GO)

Source: Internet
Author: User

Using MDI to browse child windows, with Window management function, the same screen to view the content of multiple Web pages
① Multiple Document form (MDI)
The MDI form is a form system with a master structure, and Microsoft Word is a typical example. You need at least two forms in the MDI system, one of which can only be set as the primary form, the rest of the forms are all subforms, and the main form is responsible for managing, switching, and so on. Naturally, the content that is hosted on a subform can vary. The Tidy browser finally implements three different forms: the main form, the Browse subform, and the source code subform.
② Setting the form type
We set the form type through the Formstyle property of the form, which is an enumeration type, and the desirable values are: Fsnormal, Fsmdichild, Fsmdiform, Fsstayontop. corresponding to: normal form, MDI child form, MDI main form, normal top form.
It is important to note that the Formstyle property of a form should be determined during the design period and that changes during the run are undesirable.
③ the creation of a subform
Typically, the main form is created automatically when the application starts, and the subform is usually created after responding to the user's actions. Also, the same class of child form instances can be created multiple times. To avoid creating subforms when the program starts, you can move all subforms from the Auto-create Forms window to the available by using the Form tab on the menu project\options on the IDE of the C++builder integration environment. Forms window.
④ Close of Subform
Another notable problem in MDI form technology is that the default action of the system is to minimize the user's attempt to close the subform by tapping the Close button of the MDI child form. In order for the real implementation to close the subform and free up the occupied memory, you can set the reference parameter action to Cafree in the OnClose event. The other desirable values for action are: canone,cahide,caminimize, which correspond to no action, hidden, and minimized.
⑤ use of important properties of the main form
The Activemdichild property that points to the currently active subform. This is a pointer of type Tform *, which, if necessary, can be cast to any type of child form instance.
The Mdichildcount property that is used to determine the total number of subforms that have been created.
The Mdichildren property is a pointer array of type Tform *, pointing to all the subforms that currently exist. Combined with the Mdichildcount property, you can implement a traversal of a subform.
Switching between ⑥ subforms
The method Previous (), Next (), which directly refers to the main form, enables the front and rear transitions of the subform.
⑦ the layout of a subform
The method tile (), Cascade (), which directly refers to the main form, enables you to tile the subform, cascade the layout.


>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>

Determine if the subform is open in Delphi (2008-10-07-15:21:52)
Tags: It classification: Delphi Programming
Today in a program, you need to determine whether the subform is open, write this code to share


Restrict the opening of multiple subforms in an MDI form, using traversal to determine whether the subform already exists:

Procedure Tf_main.btnupdateclick (Sender:tobject);
Var
I:integer;
Begin
For I: =0 to F_main. MDIChildCount-1 do//mdichildcount: Total number of subforms
if (F_main. Mdichildren[i] is Tf_pass) then//determine if the subform exists
Begin
Self. Mdichildren[i]. BringToFront; Put the form to the front
Mdichildren[i]. SetFocus; Form gets focus
Exit; Exit Function Body

End

Create a new form
Application.createform (Tf_pass,f_pass);
F_pass.show;
End


To turn off the subform when the Close button is clicked:

Procedure Tf_pass.formclose (Sender:tobject; var action:tcloseaction);
Begin
Action: = Cafree;
F_pass: = nil;
End

Implementing MDI Child forms in Delphi (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.