Difference between revisions of "Frames"

From Free Pascal wiki
Jump to navigationJump to search
m
Line 1: Line 1:
= What are frames? =
+
= About =
 
Frames are named containers for components and very similar to forms. There unique ability is that they can be embedded into forms or other frames in the designer. As forms they are stored in two files: the code is stored in .pas file and the design in  the .lfm file.
 
Frames are named containers for components and very similar to forms. There unique ability is that they can be embedded into forms or other frames in the designer. As forms they are stored in two files: the code is stored in .pas file and the design in  the .lfm file.
  
Line 20: Line 20:
 
For example, you have 2 listboxes and buttons to move items between them in your several project forms. So you can create a frame with 2 listboxes and needed button, write a logic of items moving and use then use your frame on all forms where needed. Moreover, if you find an error in frame code then you will fix it once in the frame code instead of fixing it n-times amoung all forms.
 
For example, you have 2 listboxes and buttons to move items between them in your several project forms. So you can create a frame with 2 listboxes and needed button, write a logic of items moving and use then use your frame on all forms where needed. Moreover, if you find an error in frame code then you will fix it once in the frame code instead of fixing it n-times amoung all forms.
  
[[Image:Frame_example.PNG]] [[Image:Frame_embedded.PNG‎]]
+
a frame in designer:
 +
[[Image:Frame_example.PNG]]  
 +
 
 +
 
 +
the frame placed on a form:
 +
[[Image:Frame_embedded.PNG‎]]
 +
 
 +
the same frame placed on another form:
 +
 
 +
 
 +
//todo:

Revision as of 14:12, 20 August 2009

About

Frames are named containers for components and very similar to forms. There unique ability is that they can be embedded into forms or other frames in the designer. As forms they are stored in two files: the code is stored in .pas file and the design in the .lfm file.

Are they VCL compatible?

Yes, frames are fully compatible with VCL.

How to create a frame?

Press File->New... menu item and in the opened dialog select "Frame" item.

Frame new.PNG

How to place a frame to the form or frame?

Standard component palette has a special component item "TFrame". When you drop it to the form or frame the IDE asks you to choose one of project frames. Frames in packages are not yet implemented. But you can create frames in code even in packages. You can't create frame circles - the IDE will forbid this, iow you can't place FrameA to FrameA and you can't place any frame which contains FrameA to FrameA.

Frame add.PNG

What can they be used for?

They are needed when you have the same set of controls and logic between them at different windows (forms) of your application. You can group that repeated controls and logic into one frame and use that frame in different places. Therefore you don't need to repeat work of control layouting and writing their logic.

For example, you have 2 listboxes and buttons to move items between them in your several project forms. So you can create a frame with 2 listboxes and needed button, write a logic of items moving and use then use your frame on all forms where needed. Moreover, if you find an error in frame code then you will fix it once in the frame code instead of fixing it n-times amoung all forms.

a frame in designer: Frame example.PNG


the frame placed on a form: Frame embedded.PNG

the same frame placed on another form:


//todo: