TreeViews and Images

Use the following code:

PROCEDURE CreateDefaultObjectIcons;

VAR Pic : TPicture;

BEGIN
  ObjectIcons:=TImageList.CreateSize(32,32);
  Pic:=TPicture.Create;
  WITH ObjectIcons, Pic.Bitmap.Canvas DO
  TRY
    {There's a more direct way for loading images into the image list, but
     the image quality suffers too much}
    Pic.Bitmap.Handle:=LoadBitmap(HInstance,'CROSS');
    AddMasked(Pic.Bitmap,Pixels[0,0]); OverlayIndex:=Count-1;
    Overlay(OverlayIndex,0); // used as indicator for disabled objects
    Pic.Bitmap.Handle:=LoadBitmap(HInstance,'UNIVERSE2');
    AddMasked(Pic.Bitmap,Pixels[0,0]); SceneRootIndex:=Count-1;
    Pic.Bitmap.Handle:=LoadBitmap(HInstance,'CAMERAS2');
    AddMasked(Pic.Bitmap,Pixels[0,0]); CameraRootIndex:=Count-1;
    Pic.Bitmap.Handle:=LoadBitmap(HInstance,'LAMPS2');
    AddMasked(Pic.Bitmap,Pixels[0,0]); LightsourceRootIndex:=Count-1;
    Pic.Bitmap.Handle:=LoadBitmap(HInstance,'OBJECTS2');
    AddMasked(Pic.Bitmap,Pixels[0,0]); ObjectRootIndex:=Count-1;
    AddMasked(Pic.Bitmap,Pixels[0,0]); StockObjectRootIndex:=Count-1;
  FINALLY
    Pic.Free;
  END;
END;

and in the tree view constructor assign 'ObjectIcons' to TTreeView.Images.
Each node you create, must be given an index into the image list. In my
sample code I use some global variables (named ...Index).

Hope this helps

Ciao, Mike

Scott Jarkoff <alt...@mindless.com> schrieb im Beitrag
<5sbvf2$...@pecan.surfline.ne.jp>...

Quote
> Is there an easy way to get a resource file with a few images, a treeview
> and an imageview to actually display the images.  I am having a hell of a
> time trying to figure it out.  Can anyone offer any ideas?

> Thanks.
> -----
> Scott Jarkoff <alt-fx>
> Schizofrenia!
> e-mail: alt...@mindless.com
> e-mail: schizo...@usa.net
> web: http://www.surfline.ne.jp/alt-fx
> -----
> Probably the earliest flyswatters were nothing more than some sort of
> striking surface attached to the end of a long stick.
> -----
> (c) 1997, Schizofrenia! ( Signature generated w/SchizoSigz! v.80 )
> Get your copy at: http://www.surfline.ne.jp/alt-fx