Mastodon
Programmierung

Add Icons to FNPListBox

[code lang=”delphi”]procedure TForm1.FnpListBox1DrawCell(Sender: TObject; Index, Col: Integer;
Rect: TRect; State: TOwnerDrawState);
Var
intIcon : Integer;
TheName : String;
NewBitmap : TBitmap;
begin
If Col = 0 Then
Begin
NewBitmap := TBitmap.Create;
TheName := Copy(FnpListBox1.Items.Strings[Index], 1, Pos(#9, FnpListBox1.Items.Strings[Index]) – 1);
intIcon := GetIconIndex(TheName, FILE_ATTRIBUTE_NORMAL);
Smalls1.GetBitmap(intIcon, NewBitmap);
with FnpListBox1.Canvas do
begin
FillRect(Rect);
Draw(Rect.Left -1, Rect.Top + 0, NewBitmap);
TextOut(Rect.Left + 2 + NewBitmap.Width, Rect.Top + 2,
TheName);
end;
NewBitmap.Free;
End;[/code]

[tags]Delphi, Components, ListBox[/tags]

0 Kommentare zu “Add Icons to FNPListBox

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.