If I compile with range checking on then I get a range check error in TryPaintBorder when it calls acgpDrawRect at the end.
The issue is with the color parameter.
The expression Cardinal(bColor) or $FF000000 produces a value that is not in the range for TColor.
Changing the expression to bColor or TColor($FF000000) solves the issue.