0
votes

I just installed Embarcadero C++Builder 10.4 Community Edition. I created a new VCL-applcation and added some components TButton and TLabel to the form. To the button I added an OnClick event:

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Button1->Caption = "Hej!";
}
//---------------------------------------------------------------------------

When I delete the button in the designer, the generated code is not deleted. From Delphi 10.4 I know,that the generated code is removed.

Is this generally not working in C++Builder and do I need to remove the code manually? I also tried a FMX application, it does not work either.

1
I doubt that Delphi 10.4 would remove the Button1Click procedure when you delete the actual button in the designer. I have never seen such behavior, which is a good thing as you might have assigned the same procedure to other objects too. So yes, if you don't need that code anymore, you need to remove it yourself. - Tom Brunberg
There is one situation where the procedure is removed, but that is not related to whether the button is still on the form or if it is deleted. That situation is if the procedure has no code at all at the time of compilation. - Tom Brunberg

1 Answers

4
votes

When I delete the button in the designer, the generated code is not deleted.

It is not supposed to. The IDE will remove an event handler only if the handler's body is completely empty. And even then, only when the unit is saved to disk, not when the component is removed from the Designer. If the handler has any code inside of it, even just comments, the IDE will leave it alone.

From Delphi 10.4 I know,that the generated code is removed.

I seriously doubt that. This behavior has been the same for many many years. There would be no reason for Embarcadero to change it now.