Recent

Author Topic: [SOLVED] Tabsheet template  (Read 3944 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[SOLVED] Tabsheet template
« on: March 21, 2021, 07:10:39 am »
Hi All,

how would I go about creating a template of a tabsheet (and if possible save to file [not needed to be editable]), and add that template as a new tabsheet?

Thanks in advance.
« Last Edit: March 21, 2021, 10:16:28 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Tabsheet template
« Reply #1 on: March 21, 2021, 08:25:44 am »
Simplest solution will probably be to design the "sheet" as a TFrame and create them as needed, with the tabsheet as Owner and Parent.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Tabsheet template
« Reply #2 on: March 21, 2021, 08:53:48 am »
Thanks.

Questions

1. Is TFrame a visual component?

If yes 1. Where do I find it
          2. How do I load / save it

If no 1. Isn't it the same as creating components at runtime and making the tabsheet the parent?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Tabsheet template
« Reply #3 on: March 21, 2021, 09:51:25 am »
Yes, it is a visual component. It's a container that can be edited almost as if it were a form, only it has to be embeded inside a form or other containers (like a panel or a tabsheet). Indeed, you can think of it as an "embedable form".

You create one by going to "File->New..." and selecting "Frame". Then you can design and program it by adding controls, setting event handlers, etc. (and load/save it) as if it were a form, with its own unit.

To use a frame you have two basic options, as with any other control: either in code or selecting TFrame in the palette (Standard tab) and clicking on the form (or other container in it); that will show you a dialog allowing you to select which frame to insert, if there is any in the project.

There is more info about them in the wiki: TFrame
« Last Edit: March 21, 2021, 09:55:55 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Tabsheet template
« Reply #4 on: March 21, 2021, 10:05:32 am »
Thanks. Looks like it might do.

Oh, just one last question before I close this thread.

So I have added a frame to my project add added the frame to a tabsheet. On the frame is a label and a button, for example. How do I change the labels caption and how do I handle the buttons onclick event?


« Last Edit: March 21, 2021, 10:15:47 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: [SOLVED] Tabsheet template
« Reply #5 on: March 21, 2021, 10:41:27 am »
Guess you already found the answer ;)

Anyway, for completeness sake, you have two ways of doing it: either change them in the specific instance you added to the tabsheet or, for a generic caption and handler that will work the same on all instances, change them in the frame itself.

The difference is that in the first case it will be specific to the particular frame you added, while the later will do the same for all frames you add(-ed).
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8551
Re: [SOLVED] Tabsheet template
« Reply #6 on: March 21, 2021, 03:31:40 pm »
Guess you already found the answer ;)

Anyway, for completeness sake, you have two ways of doing it: either change them in the specific instance you added to the tabsheet or, for a generic caption and handler that will work the same on all instances, change them in the frame itself.

The difference is that in the first case it will be specific to the particular frame you added, while the later will do the same for all frames you add(-ed).

I'd suggest editing an instantiated frame with extreme caution, it can be difficult to remove properties (i.e. revert to the frame as deigned) once they're in the form's .lfm file.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018