I have some dynamically created listview components with dozens of items, and over 24 columns.
When i set some canvas properties (brush.color, for example) in the onCustomdrawXXX
events, or onAdvancedCustomDrawXXX
events of the listview, the application gets unstable and crashes.
First, some visual glitches start to appear (header not painting, artifacts in the listview), then the app goes unresponsive and crashes.
I was able to reproduce the problem with a design-time created listview too.
I have read this, but i don't want to ownerdraw the control.
Can anyone help me with this, please?
Update: the code
procedure TMainForm.listview1AdvancedCustomDrawItem(
Sender: TCustomListView; Item: TListItem; State: TCustomDrawState;
Stage: TCustomDrawStage; var DefaultDraw: Boolean);
begin
FDefaultCanvasColor := clWindow;
if Item.SubItems[1] = 'Test' then begin
FDefaultCanvasColor := $66CCFFFF;
end;
// if i remove this line, everything is OK
(Sender As TCustomListView).Canvas.Brush.Color := FDefaultCanvasColor;
end;
The visuals are presented above (controls getting unresponsive, artifacts on the controls), then crash (YourApp.exe stopped working standard windows error message).
2nd update
I wasn't able to reproduce the problem yet, but i'm working on it.
I ended up ownerdrawing the control (despite my reluctance), that works without problems.
I will still research this problem, and if i come up with the solution will let you know.