You may not want all your VCL application's forms in memory at once. To reduce the amount of memory required at load time, your application can create forms only when it needs to make them available for use. A dialog box, for example, needs to be in memory only during the time the user interacts with it. Using RAD Studio, the following procedure creates a modal form dynamically. The main difference between dynamically creating a form and displaying an auto-created VCL form is that you remove the second form's invocation at startup and write code to dynamically create the form.
Building this VCL application consists of the following steps:
New
Other
Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon. The VCL Forms Designer displays Form1.
New
Other
Delphi Projects
Delphi Files or File
New
Other
C++Builder Files and double-click the Form icon. The VCL Forms Designer displays Form2.
Options
Forms. The Project Options dialog displays.
Use Unit. For C++, select Form1 and choose File
Include Unit Hdr The Uses Unit dialog displays.
Form2 := TForm2.Create(self); try Form2.ShowModal; finally Form2.Free; end;
Form2 = new TForm2( this );
try {
Form2–>ShowModal();
} __finally {
Form2–>Free();
}
Run. The application executes, displaying Form1. |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
|
What do you think about this topic? Send feedback!
|