Forum > General

Best way to change a component's base type


I've created some custom controls based upon TEdit and need to update an original program with newer names. How is the best way to handle this?

Example: I've created a custom control called: OldTedit which is a TEdit control that I've added additional functionality to.

Now I've created a new custom control called NewTEdit which is basically the same as OldTedit except for the name. My current version of Lazarus has the NewTEdit package added to it and NOT the OldTEdit package. If I try and load a project which uses OldTEdit, it can't find the definitions and refuses to load the old components forcing me to manually replace all of the OldTEdit based controls with NewTEdit controls. To avoid all this work, is it possible to edit the forms source and replace OldTEdit with NewTEdit?

Or is there an easier way to do this? Hopefully this makes sense?

Not sure, but maybe the refactorization tools help.  To use it, put the cursor over the OldTEdit identifier and press F12 or select from menu Source > Refactoring > Rename Identifier...  that will open a dialog with a bunch of options.  Read them carefully and try.

Note that it will work only if all units are included in the Project Inspector.

What about re defining

     OldTedit = class(NewTedit);

I think the form streaming is only linked to one such component, as streams contain the component name

Apart from the menu refactoring option, isn't ctrl-shift-E also supported?


[0] Message Index

Go to full version