procedure TfrmMain.lbLibDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var i, l, t, r, b, w, h, s, idx, w2: integer; cvs: TCanvas; found: boolean;
begin
if Icons[Index] = nil then Exit; cvs := TListBox(Control).Canvas;
cvs.Brush.Color := clWhite;
cvs.FillRect(Rect);
cvs.Pen.Color := $DBBCBC; l := Rect.Left + 1;
t := Rect.Top + 1;
r := Rect.Right - 1;
b := Rect.Bottom - 1;
w := r - l;
h := b - t; if (odSelected in State) then
begin
cvs.Brush.Color := $DBBCBC;
cvs.RoundRect(l, t, r, b, 5, 5);
end; found := False;
for i := 0 to Icons[Index].Images.Count - 1 do
begin
if Icons[Index].Images[i].Style = IconViewStyle then
begin
s := SIZES[IconViewStyle];
Icons[Index].Images[i].Draw(cvs, l + (w - s) div 2, t + (h - s) div 2);//after this system DrawFocusRect is incorrect???
found := True;
Break;
end;
end; // IconViewStyle not found, draw a symbol
if not found then cvs.RoundRect(l, t, r, b, 5, 5); if (not found) and Cfg['ColorCompatible'] then
begin
s := 0; for i := 0 to Icons[Index].Images.Count - 1 do
begin
if 32 = Icons[Index].Images[i].Info.BitCount then
begin
w2 := Icons[Index].Images[i].Info.Width;
if (w2 > s) and (w2 < SIZES[IconViewStyle]) then
begin
s := w2;
idx := i;
end;
end;
end; if s > 0 then Icons[Index].Images[idx].Draw(cvs, l + (w - s) div 2, t + (h - s) div 2);
end;
end;
var i, l, t, r, b, w, h, s, idx, w2: integer; cvs: TCanvas; found: boolean;
begin
if Icons[Index] = nil then Exit; cvs := TListBox(Control).Canvas;
cvs.Brush.Color := clWhite;
cvs.FillRect(Rect);
cvs.Pen.Color := $DBBCBC; l := Rect.Left + 1;
t := Rect.Top + 1;
r := Rect.Right - 1;
b := Rect.Bottom - 1;
w := r - l;
h := b - t; if (odSelected in State) then
begin
cvs.Brush.Color := $DBBCBC;
cvs.RoundRect(l, t, r, b, 5, 5);
end; found := False;
for i := 0 to Icons[Index].Images.Count - 1 do
begin
if Icons[Index].Images[i].Style = IconViewStyle then
begin
s := SIZES[IconViewStyle];
Icons[Index].Images[i].Draw(cvs, l + (w - s) div 2, t + (h - s) div 2);//after this system DrawFocusRect is incorrect???
found := True;
Break;
end;
end; // IconViewStyle not found, draw a symbol
if not found then cvs.RoundRect(l, t, r, b, 5, 5); if (not found) and Cfg['ColorCompatible'] then
begin
s := 0; for i := 0 to Icons[Index].Images.Count - 1 do
begin
if 32 = Icons[Index].Images[i].Info.BitCount then
begin
w2 := Icons[Index].Images[i].Info.Width;
if (w2 > s) and (w2 < SIZES[IconViewStyle]) then
begin
s := w2;
idx := i;
end;
end;
end; if s > 0 then Icons[Index].Images[idx].Draw(cvs, l + (w - s) div 2, t + (h - s) div 2);
end;
end;
Icons呢?
是否在使用这些类的代码中某些资源没有释放?
我还是认为是你自己写的类的问题。
如果找不到原因,试着先屏蔽该函数中所有代码,然后一行一行地调试,看看究竟是哪一行引起的内存泄露。