Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-03

Change type of object in form

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jürgen Hestermann

In Lazarus I added objects of type "TFileNameEdit" to my form and placed it relativ to other elements with anchor docking. Now I wanted to replace these "TFileNameEdit" objects by "TDirectoryEdit" objects without deleting the original objects and adding new ones (and loosing all visual placement). When I change the object declaration of my source code I see this change in the form designer (icon is different) but after compiling the exe file is still using the old "TFileNameEdit" object. How can this be changed (and why is the code change ignored)?

Reply by email

Jürgen Hestermann
to Juha Manninen
Juha Manninen wrote
The component is defined also in the .lfm file. The designer popup menu has "Change Class ..." which does it properly.

Thanks, it works in that respect that it replaces the object type but now all anchor references in other objects that used the replaced object are gone and I have to set them again.
So in the end it's nearly the same as if I would have deleted and recreated it.

Reply by email

Juha Manninen
to Jürgen Hestermann
J?rgen Hestermann wrote 5 lines
Thanks, it works in that respect that it replaces the object type but now all anchor references in other objects that used the replaced object are gone and I have to set them again. So in the end it's nearly the same as if I would have deleted and recreated it.

For me it works correctly. I just tested.
Maybe your earlier experiments screwed things up.
Can you reproduce it? If you can, then it is a bug and should be reported.

Juha

Reply by email

Mark Morgan Lloyd
to Juha Manninen: On Wed, Mar 13, 2013 at 6:23 PM, J?rgen Hestermann The component is defined also in the…
Juha Manninen wrote 6 lines
On Wed, Mar 13, 2013 at 6:23 PM, J?rgen Hestermann wrote: > How can this be changed (and why is the code change ignored)? The component is defined also in the .lfm file. The designer popup menu has "Change Class ..." which does it properly.

It would be useful if some more of these right-button actions could be migrated to the Object Inspector window, for cases where a component is obscured in the form designer.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Juha Manninen
to Jürgen Hestermann
J?rgen Hestermann wrote
Shure? All anchor references in the changed object were retained but references in other (not changed) objects that used the changed object were gone.

You are right. I was testing it the other way around. It is a bug indeed.

Juha

Reply by email

Juha Manninen
to Juha Manninen

The workaround is to manually edit also the .lfm file. Changing the same type in both .pas and .lfm files works, although it may complain about non-existent properties the first time you open it.

Juha

Reply by email

Mattias Gaertner
to Juha Manninen
The workaround is to manually edit also the .lfm file. Changing the same type in both .pas and .lfm files works, although it may complain about non-existent properties the first time you open it.

Keeping references *from* other components is not yet implemented for "Change Class".

Mattias

Reply by email