How to get the parent form of a component in Borland VCL?

I would like to determine what form this component belongs to in my application. Neither the property of the parent nor the owner can be considered the form itself, so I can not just use it.

I think I could just pass through the Parent property recursively until I get something received from TForm, but is there a better way to do this? I used the search function but could not find anything specific for my problem.

I am using Borland C ++ Builder, by the way (Delphi marked, because most VCL users seem to write to Delphi, and I read Delphi code perfectly).

Thanks in advance!

+6
c ++ delphi vcl c ++ builder
source share
1 answer

You can use GetParentForm in the Forms module - it is also used by VCL. It does what you mentioned - it recursively discovers the first TCustomForm in its parents. In addition, it also handles development time.

+21
source share

All Articles