Component cannot draw outside of paint method ? lazarus / 39-Graphics ---------------------------------------------------------------------- dpsoftware · 2010-06-06 07:11 I have a component for a ruler based on a TGraphocControl. It draws the ruler fine in the paint method. But in response to a mouse movement, it calls a routine to add a vertical line across the ruler. It seems that the moveto and lineto commands are not working outside the paint method although changes in penwidth remain for the next paint. Anyone know if this is a bug or a restriction and how to get around it ? Component worked fine on Delphi 6 and has been converted. TRuler = class(TGraphicControl) .. .. procedure TRuler.Paint;  { works fine } begin   with canvas do       begin     moveto(x,y)     lineto(x2,y2)   ..   .. end; procedure TRuler.setMarkerPos(iValue: Integer);  { no effect but its being called } begin   with canvas do       begin     moveto(x,y)     lineto(x2,y2)   ..   .. end; ---------------------------------------------------------------------- theo · 2010-06-06 07:50 Quote from: dpsoftware on June 06, 2010, 09:11:22 amAnyone know if this is a bug or a restriction It's a restriction afaik. On certain systems, painting outside the OnPaint event handler won't work at all. Quote from: dpsoftware on June 06, 2010, 09:11:22 am.. and how to get around it ? Paint in OnPaint, or Paint on a buffer (Bitmap) which you copy to the screen in OnPaint. ---------------------------------------------------------------------- dpsoftware · 2010-06-06 11:43 Thanks, I just did everything in paint and it works fine. The original didn't redraw after every change in mouse position but used an xor draw to update the position marker.  It doesn't seem to be a problem redrawing the entire ruler.