Recent

Author Topic: Dynamically inserting elements in a Class  (Read 528 times)

seany

  • Full Member
  • ***
  • Posts: 120
Dynamically inserting elements in a Class
« on: January 29, 2023, 03:18:30 am »
Hi

I have a relatively ambitious idea for a newcomer. This may not be possible, but I am trying to learn by investigating the limits.

Imagine, I have a folder where my lazarus project is stored. The project has a form with a panel and a richmemo. Additionally, I have defined a class called textblock with one member called text of type string.

Every time write something in the richmemo and hit enter, it creates a new instance of textblock in memory. See picture in attachment with title Image1.png please.

Now, I want to know if the following is possible; and if so how?

  • Add a new file called plugin.pas in the same directory where the main project is. This file will have a control (say a TTrackBar) defined in, with location, anchors, etc. Afterwards, if I recompile using command line, and start the executable file, then the corresponding control (in this example the TTrackBar) will appear in the panel. I understand that the plugin now has to access the main Form, (i know that it is called Form1), the panel, and create a control on top of it. But How do I do that?
  • If I now write in the Richmemo and hit enter, the original class textblock  will be extended to contain a new variable trackbarvalue of type integer. This variable name and type should also be defines inside plugin.pas . After that, the an instance of the new, extended  textblock  will be initialized, and the value of the TTrackBar should now be pushed in the class member variable instance of textblock .trackbarvalue . Is this possible? How do I do it? 

Thank you
My projects, among others:

https://linktr.ee/siderealNight

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Dynamically inserting elements in a Class
« Reply #1 on: January 29, 2023, 08:17:02 am »
type helpers.
[edit]
 For plugins use iinterfaces...
« Last Edit: January 29, 2023, 09:54:39 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018