Question

At work we have a rather large C++ VCL forms application. It compiles in Embarcadero XE2, but goes back many years. I need to add a new form to this application.

When you do "File > Add New > VCL Form" a form is created where the class name is TForm1. Also a pointer is created like so: TForm1 *Form1

For obvious reasons I want to rename the form and the pointer, to say TStuffForm and *StuffForm . Problem is I cannot get it to work!

To any actual XE2 users out there: what is the canonical way of doing this?

I have tried renaming straight in code by carefully replacing strings, but it does not work. The IDE goes nuts and fires multiple modal popups at me complaining that the TForm1 class is missing. That was so unpleasant that I gave up on it.

I also tried the refactoring functionality in the IDE as well, but that did not work either. So now I am a bit stuck.

Was it helpful?

Solution

I haven't used XE2 yet, still using RAD studio 2010. Nevertheless, the following works for me:

  • Go to the Design View of your new form.
  • Select the form from the Structure tree ( or just click on it ).
  • Change the name property of the form.

That should then change the class and class-pointer names of the unit.

Can't see why that wouldn't work in XE and later versions, but as I mentioned - not tested.

Update: Verified method works for C++ Builder 10.1 Berlin.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top