Salvador
Salvador

Reputation: 16472

see the content of an TImagelist in runtime

is possible invoke in runtime the TImagelist editor to see the contents of my TImagelist?

Upvotes: 2

Views: 1120

Answers (3)

Darkerstar
Darkerstar

Reputation: 932

CodeSite has a pretty code logger. You can use it to dump bitmap objects, and see it in the logger window.

http://www.raize.com/DevTools/CodeSite/Default.asp

Upvotes: 0

Uli Gerhardt
Uli Gerhardt

Reputation: 13991

You can drop a ListView on some form and do something like this:

var
  i: Integer;
  li: TListItem;
begin
  ListView1.LargeImages := ImageList1;
  ListView1.Items.BeginUpdate;
  try
    for i := 0 to Pred(ImageList1.Count) do
    begin
      li := ListView1.Items.Add;
      li.Caption := Format('Image %d', [i]);
      li.ImageIndex := i;
    end;
  finally
    ListView1.Items.EndUpdate;
  end;
end;

Upvotes: 6

vcldeveloper
vcldeveloper

Reputation: 7489

That editor is a design-time editor and is not available at runtime, but you can draw any of the images saved inside an ImageList on any canvas by calling its Draw method and specifying index of the image which you want to draw. The sample code below draws all images saved inside ImageList1 on Form1 in a vertical list:

var
  i : Integer;
begin
  for i := 0 to ImageList1.Count-1 do
    ImageList1.Draw(Form1.Canvas, 16, 16 + (i * ImageList1.Height),i,True);
end;

Upvotes: 6

Related Questions