I wanted to "share" my icons for my application. So I created a Datamodule, and placed an Imagelist there.
I then loaded the images into the imagelist at designtime.
When I run my application, I assign the images to my buttons at creation.
Which works... The mainform has the speed/bit buttons with their images. But then when I show form2 (which also has buttons with the same icon) the application crashes due to access violation.
Any help?
During mainform.create(...)
DataModule1.ImageList1.ShareImages := true;
DataModule1.ImageList1.GetBitmap(0, btnUntapAll.Glyph) ;
DataModule1.ImageList1.GetBitmap(1, btnDrawCard.Glyph) ;
DataModule1.ImageList1.GetBitmap(2, btnCreateToken.Glyph) ;
DataModule1.ImageList1.GetBitmap(3, btnLifeDown.Glyph) ;
DataModule1.ImageList1.GetBitmap(4, btnLifeAdd.Glyph) ;
DataModule1.ImageList1.GetBitmap(5, btnSetLife.Glyph) ;
DataModule1.ImageList1.GetBitmap(6, btnNextPlayer.Glyph) ;
In my other form (in my "formshow" procedure)
if not initialized then begin
DataModule1.ImageList1.GetBitmap(0, btnUntapAll.Glyph) ;
DataModule1.ImageList1.GetBitmap(1, btnDrawCard.Glyph) ;
DataModule1.ImageList1.GetBitmap(2, btnCreateToken.Glyph) ;
DataModule1.ImageList1.GetBitmap(6, btnNextPlayer.Glyph) ;
end;
[/code]