I'm using sets to bitpack flags, usually for communication purposes. I do the following:
type
TSetBits32 = Set of 0..31; // Use TSetBits32(LongWord) => Set
TOrdBits32 = LongWord; // Use TOrdBits32(TSetBits32) => LongWord
TMyClass = class
private
FFlags: LongWord;
function GetFlagByIndex(AIndex: Integer): Boolean;
procedure SetFlagByIndex(AIndex: Integer; AValue: Boolean);
public
property Flag0: Boolean index 0 read GetFlagByIndex write SetFlagByIndex;
property Flag1: Boolean index 1 read GetFlagByIndex write SetFlagByIndex;
{...}
end;
function TMyClass.GetFlagByIndex(AIndex: Integer): Boolean;
begin
Result := (AIndex in TSetBits32(FFlags));
end;
procedure TMyClass.SetFlagByIndex(AIndex: Integer; AValue: Boolean);
begin
if AValue
then Include(TSetBits32(FFlags), AIndex)
else Exclude(TSetBits32(FFlags), AIndex);
end;
That way I can publish individually every bit that I want, keeping them bit-packed when I want to transfer them on the wire.
You can declare FFlags as an array of TSetBits32 and subscribe like
(AIndex mod 32) in FFlags[AIndex div 32] with bigger number of bits if you want.
EDIT: Sorry, but I've completely missed the TTICheckGroup part. Still drinking my first coffee. But anyway , you can use TTIPropertyGrid in that case
