StringGrid repaint, no Cache? lazarus / 31-LCL ---------------------------------------------------------------------- gastonx · 2010-10-26 17:09 Hello, i use the "OnDrawCell" event to customize the Grid. By testing how oft repaint a cell i see StringGrid repaint by mouse move  He repaint very often, mouse move, window move... Under Mac Carbon it is very slow. How can i stop repaint by mouse move or window move? btw: I use not Hot Track, so StringGrid must not paint on mouse move ---------------------------------------------------------------------- ivan17 · 2010-10-27 04:37 and you're not doing any slow and complicated stuff in OnDrawCell handler are you? how does the grid behave if you leave only the fillrect call in the handler and nothing else? ---------------------------------------------------------------------- gastonx · 2010-10-27 08:15 thx for reply. Yes i draw Text and background. But its not to much , is only TextRect(... and FillRect with new Brush Color. Problem is StringGrid Repaint any time, biggest Problem is he paint on mouse move. my CPU goes up to 50% if i move the mouse Look at my attachment on right side CPU , is market. I have only move mouse over the StringGrid In my Code i use TListItem as Object for Cell, only for cache data. Here is my code: Code: [Select]  with StringGrid1.Canvas do   begin     if (acol>=0) and (acol<(StringGrid1.Columns.count)) then     begin       // Feldwert und Dateninhalt holen       Feld := myHeader.Values[IntToStr(aCol)];       myText := GetField(TNodeData((StringGrid1.Objects[0,aRow] as TListItem).data).data,feld);       // Wenn noch kein Paint war icon und details neu checken       if TNodeData((StringGrid1.Objects[aCol,aRow] as TListItem).data).mustrepaint then       begin         GetAnImage(Feld,mytext,acol,arow);         TNodeData((StringGrid1.Objects[aCol,aRow] as TListItem).data).mustrepaint := False;       end;       // Wenn selected dann default color ansonsten schauen ob spezialfarbe und setzen       if gdSelected in aState then Brush.Color := clHighlight else       begin         Brush.Color := clWhite;         if TNodeData((StringGrid1.Objects[0,aRow] as TListItem).data).BrushColor<>'' then         Brush.Color := StringToColor(TNodeData((StringGrid1.Objects[0,aRow] as TListItem).data).BrushColor);       end;       // Rechteckfüllen und rechts eine Line       FillRect(aRect);       Pen.Color := clSilver;       Line(arect.Right-1,0,arect.Right-1,arect.Bottom);       if brush.color<>clWhite then       begin         Line(arect.left,arect.top,arect.Right,arect.top);         Line(arect.left,arect.bottom-1,arect.Right,arect.Bottom-1);       end;       // Wenn selected Farbe Default Highlight ansonsten checken ob spezialschriftfarbe       if gdSelected in aState then Font.Color := clHighlightText else       begin         Font.Color := clBlack;         if TNodeData((StringGrid1.Objects[0,aRow] as TListItem).data).FontColor<>'' then         Font.Color := StringToColor(TNodeData((StringGrid1.Objects[0,aRow] as TListItem).data).FontColor);       end;       // Iconabstand auf 0       icospace := 0;       // Icon nun abholen :)       ico := TNodeData((StringGrid1.Objects[aCol,aRow] as TListItem).data).ImageIndex;       // Wenn Icon vorhanden dann nun ausgeben       if ico>-1 then       begin         icospace := 18;         Haupt.ImageList3.Draw(StringGrid1.Canvas,aRect.Left+3,aRect.to p+3,ico,true);       end;       // Rechteck berechnen und ggf. Icon Abstand dazu rechnen, zusätzlich Textstyle einstellen       InflateRect(aRect,-4,-4);       arect.Left := aRect.Left + icospace;       T:= TextStyle;       T.Alignment := StringGrid1.Columns.Items[aCol].Alignment;       TextStyle := T;       // Daten ausgeben wenn nicht sperre durch no text :)       if TNodeData((StringGrid1.Objects[aCol,aRow] as TListItem).data).notext<>'1' then       TextRect(aRect,arect.left,arect.top,mytext);     end;   end; ---------------------------------------------------------------------- jesusr · 2010-10-27 18:48 What Lazarus version/revision are you using? ---------------------------------------------------------------------- gastonx · 2010-10-28 07:46 Hello, I use Revision 27922 I Update this daily. ---------------------------------------------------------------------- ivan17 · 2010-10-28 09:48 i don't have mac but no amount of drawing should cause that cpu usage. try to disable your code line-by-line until you see performance improvement. than move things out of drawcell handler. or time every line (TTimer is not precise enough for that). ---------------------------------------------------------------------- jesusr · 2010-11-09 02:52 Quote from: gastonx on October 28, 2010, 09:46:05 amHello, I use Revision 27922 I Update this daily. I'm sorry for the late feedback, have you tried this in linux or windows?, if you can isolate the problem in a small sample, please submit a bug report so Mac developers can take a look at it.