[SOLVED] Painting Tshape using High CPU lazarus / 39-Graphics ---------------------------------------------------------------------- Josh · 2023-05-08 22:34 Hi probably something i am doing wrong. i have a tshape on a form and am drawing a grid on it in the onpaint event. But when it fires, the cpu usage goes through the roof. project attached. if the grid is not displayed then stretch or shrink to envoke the event, its as though it is continually being fired event code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Shape1Paint(Sender: TObject);const hm=30;var i:integer;    x1:Double;begin  if not runcode then exit;  with sender as tshape do  begin    pen.Width:=4;    pen.Color:=clwhite;    pen.Style:=pssolid;  canvas.MoveTo(0,height div 2);    canvas.Line(0,height div 2,width, height div 2);    x1:=width/hm;    pen.Width:=1;    pen.Color:=clGray;    pen.Style:=psDot;    for i:=0 to hm do canvas.Line(round(x1*i),0,round(x1*i),height);  end;end;                 forgot Lazarus 2.2.7 (rev lazarus_2_2_6-1-gada7a90f86) FPC 3.2.3 x86_64-win64-win32/win64 note the pen.width does not appear toobeyed either ---------------------------------------------------------------------- Josh · 2023-05-08 22:44 ok fixed it.my stupidity  i was not accessing the canvas pen color etc,of the form not the tshape, which caused a repaint of the tshape. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  if not runcode then exit;  with sender as tshape do  begin    canvas.pen.Width:=4;    canvas.pen.Color:=clwhite;    canvas.pen.Style:=pssolid;    canvas.MoveTo(0,height div 2);    canvas.Line(0,height div 2,width, height div 2);    x1:=width/hm;    canvas.pen.Width:=1;    canvas.pen.Color:=clGray;    canvas.pen.Style:=psDot;    for i:=0 to hm do canvas.Line(round(x1*i),0,round(x1*i),height);  end;end;