[Lazarus] derived forms and frames
tony.whyman at mccallumwhyman.com
Sat Sep 22 10:49:21 CEST 2018
It sounds like we a share a programming style as I also use lots of
derived forms and frames.
You have to use packages if you are going to work with Lazarus in this
way. Create a run-time package for your framework forms and frames and
their dependencies - you may even want more than one package in order
to structure your framework properly and to avoid having a unit in
multiple packages. Work out the package hierarchy that works best for you.
Create a design time package which registers the forms and other
components that you want to appear on the palette, plus any property
editors you need. You may also want to call "RegisterNoIcon" for any
TFrame descendents that your framework uses. This allows the IDE to
quickly find the parent class for a derived frame.
The ProjectTemplates package is also very useful here if you have any
project templates you need to register.
You will have to recompile Lazarus when you add new design time packages
- but that's just how Lazarus works. You will not have to re-compile
Lazarus every time you change a unit in a run-time package - that's only
necessary if you change the design time behaviour of a unit.
When you use your framework in your project, your run-time packages
should automatically get included if you use a form from your design
time package - otherwise just add them yourself. There is no need to
explicitly include in your project a unit define in a package on which
the project depends.
Tip: If you are editing a frame/form make sure that any descendent
frames/forms are closed, otherwise you will find that their inherited
property values are decoupled from the parent frame/form.
Hope this helps.
On 21/09/18 14:03, Franz Müller via Lazarus wrote:
> Hello everybody!
> I have been developing programs in Delphi for many years (and even
> before in turbo Pascal).
> I would like to switch all my programming from Delphi to Lazarus /
> Free Pascal.
> Now I have encountered a serious issue that I don't know how to deal
> I have built a complex framework that I use in my programs. This
> frameworks includes form templates and frame templates from which I
> derive most of the forms of a project. In order to be able to derive a
> new form from a form tempate easily with the means of the lazarus IDE,
> the form template must be part of the project - I don't see another
> way to have a form shown in the menu "file - new".
> But in order to make new published properties of the template form
> available in the object inspector, the template form must be compiled
> as part of a package.
> But for good reasons it is strongly disadvised to use the same file in
> a package and as part of the project at the same time.
> Of course, I could manually modify the source for every new unit that
> I create, but that would be rather cumbersome and error prone.
> I would like to ask if there is a solution to the problem that I am
> not aware of - otherwise I would file a feature request. I feel that
> the ability to use forms and frames derived from TForm and TFrame as a
> base for new forms is a very important feature to build an efficient
> programming framework, and this programming framework should not be
> required to be part of every project that uses it. I would suggest a
> procedure similar to "register", which should place a menu entry for
> a form or a frame from a package into the menu tree "file - new", just
> like register places a component into the component palette.
> Best regards
More information about the Lazarus