Recent

Author Topic: Creating a master form or template  (Read 1667 times)

CarmichaelJohn

  • New Member
  • *
  • Posts: 46
Creating a master form or template
« on: August 02, 2020, 03:23:32 am »
Hello,

I want to create a template (or whatever the Lazarus term is) for a form that I can use to create multiple copies of the form, only with a different set of equations on each form, Of course there would be different data on each form, but the general layout has about 50 - 60 labels, 12 edit boxes, and a Tchart component.  I cannot remember how I used to do this with Delphi because it has been years.  I want to insure that once I create the template and then derive forms from it, when I save each form under a different name I do not want the new saved form to replace any other forms or the template.  As I recall, I had a lot to trouble with this in Delphi.
I appreciate any help you might be able to provide.
John

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Creating a master form or template
« Reply #1 on: August 02, 2020, 03:19:29 pm »
Look into making TFRAMES or just FRAMEs

It allows you to build a form with the controls you want and use in multiple apps when ever you want it.

 There is plenty of documentation on it.
Start there.

https://wiki.lazarus.freepascal.org/TFrame
The only true wisdom is knowing you know nothing

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Creating a master form or template
« Reply #2 on: August 02, 2020, 04:41:04 pm »
Here's a very simple-minded example to show how to start such a program in Lazarus.

Aidex

  • Jr. Member
  • **
  • Posts: 82
Re: Creating a master form or template
« Reply #3 on: August 02, 2020, 06:20:59 pm »
The easiest way is to create a derived window from an existing window.

IDE menu: File > New... > Derived Project Component.
(I only know the german caption "Abgeleitete Projekt-Komponente")

There you select the existing window that you want to take as template.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Creating a master form or template
« Reply #4 on: August 03, 2020, 02:32:43 pm »
The English equivalent to "Abgeleitete Projekt-Komponente" is "Inherited project component".

devEric69

  • Hero Member
  • *****
  • Posts: 648
Re: Creating a master form or template
« Reply #5 on: August 03, 2020, 03:01:23 pm »
Indeed, the polymorphism of a template can be forced by depositing it in the repository of objects to inherit, and the usage of TFrames (plz, manage only 1 type of object per TFrame) in the same TForm object that will play the role of mediator between its TFrames, allow to create an efficient TForm template.
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Creating a master form or template
« Reply #6 on: August 03, 2020, 06:57:20 pm »
As a couple of others have said, TFrame for this. However watch where you edit the frame's properties: in general you only want to edit them where the frame is defined not where it's used.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

CarmichaelJohn

  • New Member
  • *
  • Posts: 46
Re: Creating a master form or template
« Reply #7 on: August 05, 2020, 07:41:40 pm »
Jamie, howardpr, Aidex, devEric89, and MarkMLI Thank you all so much for your replies.  The information you shared with me is greatly appreciated.  John

 

TinyPortal © 2005-2018