procedure PaintThemedGroupBox;
var
SavedDC: hdc;
OuterRect: TRect;
Box: TThemedButton;
Details: TThemedElementDetails;
begin
with Canvas do begin
OuterRect := ClientRect;
OuterRect.Top := CaptionMargin.Top + CaptionHeight div 2;
if not ParentColor then // <<< Also done below
FillDC(Handle, MkRect(Self), Color); // <<< Also done below
if Enabled then
Box := tbGroupBoxNormal
else
Box := tbGroupBoxDisabled;
Details := acThemeServices.GetElementDetails(Box);
acThemeServices.DrawElement(Handle, Details, OuterRect);
SelectClipRgn(Handle, 0);
SavedDC := SaveDC(Handle);
try
IntersectClipRect(Handle, CaptionRect.Left – CaptionMargin.Left,
CaptionRect.Top – CaptionMargin.Top,
CaptionRect.Right + CaptionMargin.Right,
CaptionRect.Bottom + CaptionMargin.Bottom);
Details := acThemeServices.GetElementDetails(ttBody);
if ParentColor then
acThemeServices.DrawParentBackground(Self.Handle, Handle, @Details, False)
else
FillDC(Handle, MkRect(Self), Color);
finally
RestoreDC(Handle, SavedDC);
end;