LMD DesignPack Guide


Working with Frames


Suppose you have created new project in Delphi IDE. Add a frame to this project by clicking on File|New|Frame main menu item. This will open the new unit with a frame. In designer architecture this frame instance is called base-frame. Now try to place the frame on the project's main form by selecting "frames" button on component palette, choosing our frame and clicking on the main form. You will see the newly inserted frame instance on the form. This instance is called frame-copy.

 

Note that since that, you have two distinct frame instances in the Delphi IDE: the base-frame and its frame-copy. Any count of frame-copies that will correspond to single base-frame can be added to designing forms.

 

What the instance of the base-frame is for?

 

Mainly the base-frame instance is used with designer to design it. That is you rarely need to move/resize controls in the frame-copies, instead you do this in the designer that works with base-frame instance.

Then all frame-copies places on project forms are saved relatively to its corresponding base-frame instances. The dfm writer use base-frame instance to lookup for original property values when saving frame-copy. If some property of the frame-copy or one of its child have same value as in corresponding base-frame, the writer will not include that property into parent form dfm. This leads to following important consequence: the properties will be saved only once, in base-frame dfm, so this normalization allows to make no-changes to forms dfms, when changing base-frame. That is other project forms can even be not opened in IDE while changing base-frame layout.

 

How the root with frame-copies is loading?

 

Since the form dfm does not include all frame-copy properties, how to properly initialize the frame-copy while loading? The answer is to provide the base-frame to the form reader. That is every frame-copy loaing in two steps: first frame-copy and its children is initialized with base-frame property values, then the properties that has different from base-frame values are readed from forms dfm.

 

As opposed to other designer tool sets LMD-DesignPack provides two ways for providing a base-frame while loading a frame-copy:

 

Provide a link to the base-frame instance by calling LMDLoadFrameBase method and passing base-frame module as the method parameter.

Initialize the frame-copy from the stream or file that contains saved base-frame by calling another overloaded LMDLoadFrameBase method providing a link to the stream or file name.

 

In the IDE-Tools the instance of the base-frame is implied to exist in design-time mode. So, the first way should be usually used for providing a base-frame instance in the IDE application. Also note, that commonly if the opening in IDE form contain frame-copies of the not yet opened in IDE base-frame module, this module should be immediately opened (recursively).

 

As opposed to design-time, at run-time NO additional frame instances, except frame-copies are expected. That is the base-frame instance should not be created at run-time. This is very important, because the frame  can contain heavy components, like database connections or opened tables, and fake base-frame instance will unnecessary eats computer resources. So, the advantage of the LMD-DesignPack is that it allows to initialize frame-copy from previously saved (at design-time) base-frame stream or file.

 

See also TLMDModule.OnQueryFrameData event to learn of how to provide a base-frame data for the frame-copies.