PolyLine problems lazarus / 39-Graphics ---------------------------------------------------------------------- mtanner · 2017-01-07 18:08 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. ---------------------------------------------------------------------- bytebites · 2017-01-07 19:10 You fill TestPoint-array and paint TestPoints-array. ---------------------------------------------------------------------- derek.john.evans · 2017-01-08 04:13 Try using moveto/lineto's and see if you get what you want. ---------------------------------------------------------------------- mtanner · 2017-01-08 08:38 Thanks for the comments. I discovered what the problem, or at least the solution, is. Height and Width of the control seem unreliable. If I use ClientRect.Right and ClientRect.Bottom instead, then I get the results I expect. Though I do not understand why the Height/Width of the control shouldnot work ok.