How to change PolyLine colour? lazarus / 39-Graphics ---------------------------------------------------------------------- JoshM · 2014-01-02 20:37 I'm using the function: function Polyline(DC: HDC; var Points; Count: Integer): BOOL; external 'gdi32' name 'Polyline'; Using the Canvas.Pen.Color code doesn't work, as (I think) the function I'm using a built-in Windows one, and not a Pascal/Lazarus one. Does anyone know how I could change the colour of the PolyLine, or where I could go about getting this info? Here's the code I've got, with comments to explain what I want: Code: [Select] procedure TNewPageControl.PaintWindow(DC: HDC); begin   inherited PaintWindow(DC);   //set colour = black   PolyLine(DC, Points, PointNum);   //set colour = red   PolyLine(DC, VerVec, PointNumVec);   //set colour = green   PolyLine(DC, HorVec, PointNumVec); end;         Thanks. ---------------------------------------------------------------------- howardpc · 2014-01-02 21:20 You use a valid canvas (of a form or other control), setting its Pen/Brush colour as desired, and then pass Code: [Select]canvas.Handle as the first parameter to Polyline(...); You probably don't need to call PaintWindow() at all. ---------------------------------------------------------------------- taazz · 2014-01-02 21:23 Canvas.Polyline is not good enough? In short you have to make sure that the dc has everything setup before you try do anything. Try saving the canvas.handle in to a local variable that will force the canvas to set up the dc correctly for you, using its internal brush, pen and font classes. In case that you want to avoid using the canvas all together then you need to use createpen, createbrush etc after that you call the SelectObject function to let the dc know which pen and brush you want to use and then you draw your polyline. Reference :http://msdn.microsoft.com/en- us/library/windows/desktop/dd162957%28v=vs.85%29.aspx