27th
Окт

Как втавить Image в ListBox?

Posted by Chas under Пост-обзор

//Необходимо установить стиль ListBox’а в lbOwnerDrawFixed или lbOwnerDrawVariable. В первом случае высота строк будет фиксированной.
var
  Form1: TForm1;
  Bit:TBitmap;

implementation

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var cc:TCanvas;
begin
  cc:=(Control as TListBox).Canvas cc.FillRect(rect);
  cc.Draw(Rect. style="color: #006600">Left+100,Rect.Top,Bit);
  cc.TextOut(Rect.Left,Rect.Top,’safsdf’);
end;

procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);
begin
  if index=1 then Height:=24 else Height:=16;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Bit:=TBitmap.Create;
  Bit.LoadFromFile(‘i:\arr2.bmp’);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Bit.Destroy;
end;

Тема на форуме

Похожие статьи

Теги: | |