I want to draw some themes parts to several TImages. In my code below, GetElementDetails
expects a certain enum value. I have the PTypeInfo
for the enum type, but I don't know how to type-cast i
to the enum type.
procedure TForm1.Button1Click(Sender: TObject);
procedure drawType(c: tcanvas; ti: ptypeinfo);
var
r: trect;
i: integer;
details: TThemedElementDetails;
begin
r.Left := 0; r.Top := 0; r.Right := 19; r.Bottom := 19;
for i := GetTypeData(ti).MinValue to GetTypeData(ti).MaxValue do begin
// How to cast i to the enum type of ti?
details := StyleServices.GetElementDetails( ???(i) );
StyleServices.DrawElement(c.Handle, details, R);
if (i mod 10 = 0) and (i > 0) then begin
r.Left := 0; r.Right := 19; r.Top := r.Bottom + 3; r.Bottom := r.Bottom + 22;
end
else r.Inflate(-22,0,22,0);
end;
end;
begin
drawType(image1.canvas, typeinfo(TThemedToolBar));
drawType(image2.canvas, typeinfo(TThemedButton));
drawType(image3.canvas, typeinfo(TThemedCategoryPanelGroup));
drawType(image4.canvas, typeinfo(TThemedComboBox));
end;
I need to cast i
to the type passed as second variable (TThemedToolBar
, TThemedButton
, etc.). How can I solve this?