I have an application that has 15 Buttons on a form. Each button can be Enabled as required and there are no set configurations so there could dozens of combinations.
To set Btnxxx.Enabled, I am currently using,
procedure TForm1.SetButtons(aStr : String);
// aStr can be '123456789ABC' for all Enabled
// or '123_567__ABC' for all-but 4, 8 and 9 Enabled
begin
btnInsert.Enabled:=Pos('1',aStr);
btnVariety.Enabled:=Pos('2',aStr);
This is getting cumbersome and error prone when I add or delete buttons. I tried using Boolean instead of aStr as in
const
aInsOn = True;
aInsOff = False;
aVarOn = True;
aVarOff = False;
procedure TForm1.SetButtons(InsOnOf, VarOnOff ... for 15 buttons : Boolean);
begin
btnInsert.Enabled:=InsOnOff;
btnVariety.Enabled:=VarOnOff;
Calling SetButtons would be
SetButtons(aInsOff, aVarOn, .......);
but that too was less than ideal with huge strings of Boolean settings.
I also tried using the Tag in similar fashion to the aStr example, but it too is error prone.
Does anyone have a pet-idea for doing this? I have not been able to make Actions work due to the unknown combinations of Enabled states of the buttons at any given time.