How does ParentBackground work for creating forms in the IDE?

This code works fine with the form created in the IDE in the VCL Forms application:

Self.ParentBackground := True; 


But why? None of the descendants ( TForm , TCustomForm , TScrollingWinControl ) publish the protected ParentBackground TWinControl property. The type declaration for the form (fi 'TForm1') at the top of the block is also not. Indeed, as expected, this

 TForm(Self).ParentBackground := True; 

not compiled ("Cannot access protected character TWinControl.ParentBackground"). Same thing with any form created at runtime.


Note Question: not about how I can set the property (BTW, there are others, for example "Bevel [xxx]") I would like to know how this works.

+4
source share
2 answers
 Self.ParentBackground := True; 

compiles because the class can access its protected members.

+7
source

But TForm1(Self).ParentBackground works. The difference is that the TForm1 class (which Self belongs to) is declared in the same unit; then you can really access protected members.

+4
source

All Articles