Recent

Author Topic: divide a Unit to several Units  (Read 1656 times)

stefanE

  • Newbie
  • Posts: 5
divide a Unit to several Units
« on: March 06, 2025, 04:48:57 pm »
Hello everybody,
i wrote a application using TPageControll.
This works well. I have all event routines in the main unit, but now i would like to add some pages to the TPageControl and the amount of event-routines becomes to much. So it is difficult to navigate through the lines.
What is the easiest way to divide the unit, so that i have a unit per Page of the TPageControl component.

Thanks in advance

stefan

cdbc

  • Hero Member
  • *****
  • Posts: 2108
    • http://www.cdbc.dk
Re: divide a Unit to several Units
« Reply #1 on: March 06, 2025, 05:29:43 pm »
Hi
Use 'TFrame's and create them dynamically, NOT via Object Inspector.
It's ok to design them with OI, but don't instantiate them that way.
Search the forum, lots written about that.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

wp

  • Hero Member
  • *****
  • Posts: 12773
Re: divide a Unit to several Units
« Reply #2 on: March 06, 2025, 05:44:28 pm »
I am attaching an example where I recently did the same that you are planning: Look at the sample project in folder components/tachart/demo/area of your Lazarus installation. It contains a page control with a chart demo on each tab sheet - it is very confusing because the code needed by each tab sheet is mixed together. In the new version which I am attaching, there is a TFrame per tabsheet. Each frame contains the components and their code for each tabsheet in a separate unit and is completely independent of the other frames. The frames are added to the tabsheets of the mainform at runtime.
« Last Edit: March 06, 2025, 05:57:39 pm by wp »

cdbc

  • Hero Member
  • *****
  • Posts: 2108
    • http://www.cdbc.dk
Re: divide a Unit to several Units
« Reply #3 on: March 06, 2025, 06:16:48 pm »
Hi
That is so cool Werner, Thanks mate. I've got one project that shows it, but it's way too involved to be used as an example...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

stefanE

  • Newbie
  • Posts: 5
Re: divide a Unit to several Units
« Reply #4 on: March 07, 2025, 11:34:05 am »
this works great!

thank you

wp

  • Hero Member
  • *****
  • Posts: 12773
Re: divide a Unit to several Units
« Reply #5 on: March 27, 2025, 04:39:24 pm »
What do you want the zip attachment to demonstrate? Strange: an exe file, config.sys, no source code, ...

cdbc

  • Hero Member
  • *****
  • Posts: 2108
    • http://www.cdbc.dk
Re: divide a Unit to several Units
« Reply #6 on: March 27, 2025, 05:06:24 pm »
Hi
Werner he's trolling, with the objective to waste everyone's time.
Every post he makes is pure useless nonsense.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

TRon

  • Hero Member
  • *****
  • Posts: 4329
Re: divide a Unit to several Units
« Reply #7 on: March 27, 2025, 05:28:34 pm »
Although I disapprove of providing an upx packed win PE32 executable as well it does seem to have a purpose. It is the code that produces the animated gif. Not that I've tested it but I can read disassembly and make an educated guess based on the components used.

btw: hiren boot cd, now /that/ is a blast from the past  :)
Today is tomorrow's yesterday.

mm7

  • Full Member
  • ***
  • Posts: 222
  • PDP-11 RSX Pascal, Turbo Pascal, Delphi, Lazarus
Re: divide a Unit to several Units
« Reply #8 on: April 07, 2025, 10:50:33 pm »
Hello everybody,
i wrote a application using TPageControll.
This works well. I have all event routines in the main unit, but now i would like to add some pages to the TPageControl and the amount of event-routines becomes to much. So it is difficult to navigate through the lines.
What is the easiest way to divide the unit, so that i have a unit per Page of the TPageControl component.

Thanks in advance

stefan

You can move procedures to .inc files.

 

TinyPortal © 2005-2018