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)?
Mailing lists / lazarus / 2013-03
Change type of object in form
9 messages · 4 people · –
- JJuha Manninen 4
- JJürgen Hestermann 3
- MMark Morgan Lloyd 1
- MMattias Gaertner 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
J?rgen Hestermann wroteHow 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.
Juha
Juha Manninen wroteThe 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.
J?rgen Hestermann wrote 5 lines
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
On Wed, Mar 13, 2013 at 6:23 PM, J?rgen Hestermann The component is defined also in the…
Juha Manninen wrote 6 lines
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.
On Wed, Mar 13, 2013 at 7:12 PM, J?rgen Hestermann For me it works correctly. I just…
Juha Manninen wroteFor me it works correctly. I just tested.
Shure? All anchor references in the changed object were retained but references in other (not changed) objects that used the changed object were gone.
Maybe I find some time to investigate more in it but as so often, I actually wanted to do code and bugfix *my* program. ;-)
J?rgen Hestermann wroteShure? 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
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
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
