ich habe ein etwas skurriles Problem und möchte fragen, ob mir da jemand auf die Sprünge helfen kann. Ich habe eine ListBox, die ich vollständig selbst zeichne (lbOwnerDrawVariable). Die eigentliche Zeichnung mache ich mittels eines BGRABitmap und kopiere sie dann auf das Canvas der Listbox. Das funktioniert soweit, solange ich die Heaptrc-Unit verwende (Unter Projekt->Projekteinstellungen->Debuggen), und sieht so aus: Wenn ich nun aber die Heaptrc-Unit nicht verwende (ohne -gh), habe ich eine flackerhafte Ausgabe, welche so aussieht: Mein Code zur Grafikanzeige:
Code: Alles auswählen
procedure TfrmSongs.SlideTextListBoxDrawItem(Control: TWinControl;
Index: Integer; ARect: TRect; State: TOwnerDrawState);
var
ABitmap:TBgraBitmap;
begin
if Index > SlideTextListBox.Count then Exit;
ABitmap := TBgraBitmap.Create;
ABitmap.FontHeight:=Round(Screen.SystemFont.Height/0.75);
ABitmap.FontName:=Screen.SystemFont.Name;
ABitmap.FontQuality:=fqFineAntialiasing;
if frmPresent.SlideList.Items[Index].SlideType = TitleSlide then
begin
ABitmap.FontStyle+=[fsBold];
ABitmap.DrawLine(2,2,ARect.Width,2,clBlack,true);
end;
ABitmap.SetSize(
ARect.Width,
ABitmap.TextSize(SlideTextListBox.Items[Index],SlideTextListBox.Width).Height + 10
);
if SlideTextListBox.ItemIndex=Index then
ABitmap.FillRect(3,3,ABitmap.Width-3, ABitmap.Height-3, clActiveCaption, dmSet);
ABitmap.DrawLine(0,0,0,ARect.Height,clBlack,True);
ABitmap.DrawLine(ARect.Width-2,0,ARect.Width-2,ARect.Height,clBlack,True);
ABitmap.TextRect(Rect(5,5,ABitmap.Width-5, ABitmap.Height-5),
SlideTextListBox.Items[Index], taLeftJustify, tlTop,
ColorToRGB(clBtnText)
);
if (Index >= frmPresent.SlideList.Count-1) or
(frmPresent.SlideList.Items[Index].Song.FileNameWithoutEnding <>
frmPresent.SlideList.Items[Index+1].Song.FileNameWithoutEnding) then
ABitmap.DrawLine(0,ARect.Height-2,ARect.Width,ARect.Height-2,clBlack,true);
ABitmap.Draw(SlideTextListBox.Canvas, ARect.Left, ARect.Top, true);
ABitmap.Destroy;
end;
Viele Grüße und Danke!