Я хочу нарисовать некоторые части темы для нескольких TImages. В моем коде ниже GetElementDetails
ожидает определенное значение перечисления. У меня есть PTypeInfo
для типа перечисления, но я не знаю, как преобразовать i
в тип перечисления.
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
к типу, переданному как вторая переменная (TThemedToolBar
, TThemedButton
и т. д.). Как я могу это решить?
this question
. - person TLama   schedule 06.08.2014