procedure TForm1.fillimagelist();
var
aSize: TSize;
aBMP: TBitmap;
aDetails: TThemedElementDetails;
aRect: TRect;
begin
ImageList1.Clear;
aDetails:= ThemeServices.GetElementDetails(tbCheckBoxUncheckedNormal);
aSize:= ThemeServices.GetDetailSize(aDetails);
ImageList1.Width:= aSize.cx;
ImageList1.Height:= aSize.cy;
aBMP:= TBitmap.Create;
with aBMP do
begin
SetSize(aSize.cx, aSize.cy);
Transparent:= True;
TransparentColor:= clForm;
Brush.Color:= TransparentColor;
Canvas.FillRect(0,0, Width,Height);
end;
aRect:=Rect(0, 0, aSize.cx, aSize.cy);
// 0 - tbCheckBoxUncheckedNormal - none selected
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
// 1 - tbCheckBoxCheckedNormal - all selected
aBMP.Canvas.FillRect(0,0, Width,Height);
aDetails:=ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal);
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
// 2 - tbCheckBoxMixedNormal - mixed selection
aBMP.Canvas.FillRect(0,0, Width,Height);
aDetails:=ThemeServices.GetElementDetails(tbCheckBoxMixedNormal);
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
// 3 - tbCheckBoxUncheckedDisabled - unchecked disabled
aBMP.Canvas.FillRect(0,0, Width,Height);
aDetails:=ThemeServices.GetElementDetails(tbCheckBoxUncheckedDisabled);
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
// 4 - tbCheckBoxCheckedDisabled - checked disabled (e.g. 3d descriptor when tbOnly2D checked)
aBMP.Canvas.FillRect(0,0, Width,Height);
aDetails:=ThemeServices.GetElementDetails(tbCheckBoxCheckedDisabled);
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
// 5 - tbCheckBoxMixedDisabled - mixed selection disabled
aBMP.Canvas.FillRect(0,0, Width,Height);
aDetails:=ThemeServices.GetElementDetails(tbCheckBoxMixedDisabled);
ThemeServices.DrawElement(aBMP.Canvas.Handle, aDetails, aRect, nil);
ImageList1.Add(aBMP, nil);
FreeAndNil(aBMP);
end;