I am looking for some BCB code to iterate over the controls on a form and get some information about them.
I tried using myForm->ControlCount and
Here it is:
void EnumerateAll(TComponent *container)
{
// Enumarate its children
for (int i = 0; i < container->ComponentCount; i++)
{
// extract the control at index i
TComponent *child = container->Components[i];
if ( child->InheritsFrom (__classid(TComponent)) ) //this check is optional
Form3->Memo->Lines->Add(child->Name);
}
}
Usage:
EnumerateAll(MyForm);
The function above will enumerate also the menu items.
Also see: C++ builder - enumerate components on TPanel
Here are more details about the VCL hierarchy: http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Class_library