unit MainForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
RTTICtrls;
type
TColor = (red, blue, green, c4, c5, c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16,
c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,
c31,c32);
TColors = set of TColor;
{ TfrmMain }
TfrmMain = class(TForm)
Button1: TButton;
TICheckGroup1: TTICheckGroup;
TIComboBox1: TTIComboBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FColor: TColor;
IColors: integer;
function getColors: TColors;
procedure setColors(AValue: TColors);
published
property Colors : TColors read getColors write setColors;
property Color: TColor read FColor write FColor;
public
end;
var
frmMain: TfrmMain;
implementation
{$R *.lfm}
function TfrmMain.getColors: TColors;
begin
Result := TColors(IColors);
end;
procedure TfrmMain.setColors(AValue: TColors);
begin
IColors := Integer(AValue);
end;
procedure TfrmMain.FormCreate(Sender: TObject);
var
acolor: TColor;
ts: string;
begin
TIComboBox1.Link.TIObject:= Self;
TIComboBox1.Link.TIPropertyName:= 'Color';
TICheckGroup1.Link.TIObject:= Self;
TICheckGroup1.Link.TIPropertyName:= 'Colors';
// with TiCheckGroup1 do begin
with TiComboBox1 do begin
with Items do begin
Clear;
Add('Red');
Add('Blue');
Add('C6');
Add('C22');
end;
with Link.AliasValues do begin
Clear;
for aColor in TColor do begin
writestr(ts, aColor);
Add(Format('%s=%s', [ts, uppercase(ts)]));
end;
end;
end;
end;
procedure TfrmMain.Button1Click(Sender: TObject);
var
ts: string;
begin
// ShowMessageFmt('FColor:%d, IColor:%d', [SizeOf(FColors), SizeOf(IColors)]);
// WriteStr(ts, Color);
// ShowMessage(ts);
// ShowMessage(InttoStr(IColors));
ShowMessage(BoolToStr(Red in Colors, true));
end;
end.