Forum > LCL

Using the same frame multiple times

(1/7) > >>

Once the LCL has initialised a frame that has been placed on a form by the IDE, is it possible (and safe) to manually copy (the reference to) that frame to e.g. a different notebook page or possibly to a different modal form?

The scenario is that I'm writing a control program for a small/cheap bench instrument, and while by-and-large there's an intuitive flow through notebook pages there's one place where I need to duplicate some settings. However the instrument's own UI uses switching between pages to start/stop various activities, and I'm trying to preserve that as far as possible in the notebook flow.

So there's one place where I need to refer to the content of a different notebook page, preferably without switching notebook pages as such.


mas steindorff:
Who will be the frame's parent?
Who frees the frame on close? 
May be better to have 2 frames work one record/set of data,

Maybe, yes. I'm still working through the possibilities: one, which might work out to be the simplest to code, is to inhibit the "switching page changes mode" behaviour when in one particular mode.

This is for a JDS6600 signal generator which has a multi-page LCD UI, but if you send it commands over the USB/serial connection you can get it to e.g. change signal burst properties on the fly.


@MarkMLI: I was fiddling with frames too, and (mistakenly) thought they'd be stored in some central (to lazarus) repository, but alas, when I tried to use the same frame in another project...  %) Then I tried the manual way, copying the frame-files and inserting in lpi-file and uses clause, then put it on tabsheet in the other project, it kinda worked, but was all botched  :'( Who would have thunk it... I haven't started digging in the ide yet, but i my mind, there has to be a better way? I thought frames were for code reusing.
Regards Benny

I don’t know if this is relevant , but I use frames with tcdpagecontrol and destroy them when I change pages and store the relevant data in an inifile. 
 In this way a frame on one page can  update data in the inifile pertaining to another frame. When the frame is recreated the data will be retrieved from inifile.

The term frame can be confusing because it means so many things on different platforms. When it comes to lazarus it’s best to think of it as a gui control.

Mark in my experience it’s better to create frames at runtime if you plan to reuse them.


[0] Message Index

[#] Next page

Go to full version