文章目录
Listbox中显示位图
提示:这里可以添加技术概要
核心源码
procedure CenterText(Cnv: TCanvas; Rect: TRect; S: string);
var
X, Y: Integer;
begin
X := (Rect.Right + Rect.Left - Cnv.TextWidth(S)) div 2;
Y := (Rect.Bottom + Rect.Top - Cnv.TextHeight(S)) div 2;
Cnv.TextOut(X, Y, S);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with ListBox1.Items do
begin
Clear;
ListBox1.Style := lbOwnerDrawVariable;
AddObject(‘Bitmap1’, Image1.Picture.Bitmap);
Self.DoubleBuffered := true;
end;
end;