You could use the Tag property of the controls and create your own grouping.
void TForm1::SetControlState(TWinControl *WinCtrl, const bool IsEnabled, const int TagValue)
{
// set the enabled property for each control with matching TagValue
for (int Index = 0; Index < WinCtrl->ControlCount; ++Index)
{
if (WinCtrl->Controls[Index]->Tag == TagValue)
{
WinCtrl->Controls[Index]->Enabled = IsEnabled;
}
// set child controls
if (WinCtrl->Controls[Index]->InheritsFrom(__classid(TWinControl)))
{
TWinControl *TempWinCtrl;
TempWinCtrl = static_cast<TWinControl *>(WinCtrl->Controls[Index]);
SetControlState(TempWinCtrl, IsEnabled, TagValue);
}
} // end for
}
Alternatively, If you want to enable/disable all controls in one go.
void TForm1::SetControlState(TWinControl *WinCtrl, const bool IsEnabled)
{
// set the enabled property for each control with parent TabSheet
for (int Index = 0; Index < WinCtrl->ControlCount; ++Index)
{
WinCtrl->Controls[Index]->Enabled = IsEnabled;
// disable child controls
if (WinCtrl->Controls[Index]->InheritsFrom(__classid(TWinControl)))
{
TWinControl *TempWinCtrl;
TempWinCtrl = static_cast<TWinControl *>(WinCtrl->Controls[Index]);
SetControlState(TempWinCtrl, IsEnabled);
}
} // end for
}
Examples:
// disable all controls on the form
SetControlState(Form1, false);
// disable all controls on a tabsheet
SetControlState(TabSheet1, false);
NOTE: The above code has been tested with C++Builder 2007