开发者

see the content of an TImagelist in runtime

开发者 https://www.devze.com 2023-01-25 05:50 出处:网络
is possible invoke in runtime t开发者_JAVA百科he TImagelist editor to see the contents of my TImagelist?That editor is a design-time editor and is not available at runtime, but you can draw any of the

is possible invoke in runtime t开发者_JAVA百科he TImagelist editor to see the contents of my TImagelist?


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;


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;


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

0

精彩评论

暂无评论...
验证码 换一张
取 消