I have a simple component, created in code, based on TGraphicControl, also tried TPaintBox. Just to start, I'm just trying to draw a line around the canvas area, with thickness of the line set by a variable, call it PenWidth. In the Paint routine I set up the Pen, and then have:
var TestPoints:array[0..4] of TPoint;
var XL,XR,YT,TB:integer;
XL:=PenWidth;
XR:=Width-PenWidth;
YT:=PenWidth;
YB:=Height-PenWidth;
TestPoint[0]:=TPoint(XL,YT);
TestPoint[1]:=TPoint(XR,YT);
TestPoint[2]:=TPoint(XR,YB);
TestPoint[3]:=TPoint(XL,YB);
TestPoint[4]:=TPoint(XL,YT);
Canvas.PolyLine(TestPoints);
My problem is that I get a line across the top, and down the left side of the canvas area. However much I try reducing the values of XR and YB (so they are definitely within the canvas area) the lines do not appear.
I think I must be doing something idiotic. This is such a simple problem I just cannot see why it's not working.