TImage and LoadFromLazarusResource() lazarus / 8-Other ---------------------------------------------------------------------- Bart · 2006-01-28 17:56 Hi there, I have a form with a TImage on it. In a resource file (made with "lazres xpmres.lrs appicon.xpm") there is a XPM icon called "appicon". I linked in the resource with:Code: [Select]initialization   {$I utest.lrs}   {$I xpmres.lrs} When I run this code:Code: [Select]begin   try     Image1.Picture.Graphic.LoadFromLazarusResource('appicon');   except     showmessage('Oops !');   end; end; it will give me the "Oops!" message (no Icon loaded in Image1). Now I runCode: [Select]begin   try     Image1.Picture.LoadFromFile('f:\lazarus projecten\9.xpm');   except     showmessage('Error on LoadFromFile'');   end; end; this will load the "9.xpm" icon into Image1. Now comes the strange part. If I now run the first code again, the "appicon" will now load from the resource. I cannot figure out what's going on here. FYI: OS: WinME (Dutch) Lazarus version: 0.9.10 beta Lazarus date: 2005-10-05 What am I doing wrong? Bart ---------------------------------------------------------------------- matthijs · 2006-01-29 11:58 Maybe you can create a backtrace on the error? This might give people who know about it a clue. ---------------------------------------------------------------------- Anonymous · 2006-01-29 12:28 Graphic of TPicture needs to be initialized. That's why you get an AV on first try. After loading a bitmap it is initialized as a bitmap. You can use Image1.Picture.Pixmap.LoadFromLazarusResource('appicon'); ---------------------------------------------------------------------- Bart · 2006-01-30 17:52 Quote from: "Anonymous"Graphic of TPicture needs to be initialized. That's why you get an AV on first try. After loading a bitmap it is initialized as a bitmap. You can use Image1.Picture.Pixmap.LoadFromLazarusResource('appicon'); OK, that explains it. The code you supplied works perfectly, thank you. Related with this item I seem not to be able to perform any LoadFromFile operations on the Application.Icon. Do I need to initialize this first too, and how to do that then? Bart