Almost all of the formal C + + Builder programs have subordinate forms, sometimes dialog boxes, and sometimes modeless windows, in addition to the main form. VCL makes it easy to create and display dependent forms. But not all programs are suitable for modeless forms, and some programs need to display different content in one main window. This article discusses how to "inhabit" a subordinate form in the main form, which appears to be part of the main form, and the user does not even know that a form is being displayed. Figure A shows a main form whose client area is a form.
Understanding Child/Parent Contact
The basic idea of such a program is to make all subordinate forms a subform of the main form, which is common in other frameworks, such as Owl or MFC, but is not common in VCL programs. VCL does not allow you to simply specify a property so that a form belongs to another form, and it takes a little work to do that. You have to tell Microsoft. Windows subordinate forms are child objects of the main form, and in C + + Builder programming It is generally considered that the form is a window and that the component is a child object, which is actually a window from the standpoint of Windows. You can add any window
(Forms and symbols) are specified as child objects of another window as long as you jump out of the VCL circle temporarily.
Better "mousetrap."
One of the benefits of attaching a form to a main form is that you can design a subform just as you would any other subordinate form, which means you create a new form, add components to it, and write code for the form. This makes it easy to design your subform and centralizes all the code that manipulates the subform in one place.
Examples of programming
First, the background of the program, the program named parenting, there is a main form, the main form of the top and bottom each have a toolbar (Tool bar) and the status bar (state bars), in addition to the main form, there are two subforms, one called Ttableform, The ANIMAL.DBF datasheet is displayed with a grid, and the animal table is a table of database samples from the C + + Builder. Another subform Tchartform displays the animal table with Tchart. (If you buy C + + Builder is a standard version and no database components) you can choose to display a form or a graphic form by clicking on a menu item or a tool button. When you make a choice, the active form is destroyed and the selected form is displayed, and the subform is displayed below the toolbar of the main form and the client area above the status bar. And keep the client area at all times with the main form size change.