Board index » delphi » bitmaps in resource-file

bitmaps in resource-file

Hi all,

I would like to put my .bmp's in a resource-file. I tried loadbitmap,
but I can't assing it to a TBitMap.
So, what am I doing wrong??

Now I have to use loadfromfile, and I wan't to get rid of that method.

Thnx in advance, Michel

 

Re:bitmaps in resource-file


Quote
e...@cbs.nl (Erwin Kalvelagen) wrote:
>I would like to put my .bmp's in a resource-file. I tried loadbitmap,
>but I can't assing it to a TBitMap.
>So, what am I doing wrong??

Loadbitmap returns Hbitmap (WinAPI type). Tbitmap.assign accepts a
Tbitmap (Delphi type). Should use Tbitmap.handle:=Loadbitmap(..).

Regards
Wai Wong

Re:bitmaps in resource-file


Quote
e...@cbs.nl (Erwin Kalvelagen) wrote:
>Hi all,
>I would like to put my .bmp's in a resource-file. I tried loadbitmap,
>but I can't assing it to a TBitMap.
>So, what am I doing wrong??

First, start a new .res file (with the image editor) and put your
bitmaps in that file.  But, don't save this new file as the same name
as your project.  Delphi maintains that one and you'll lose your
bitmaps.  Then, include the following line after your {$R *.DFM} line
in the Implementation area:

{$R yourfilenamehere.RES}

Then, in your code, do the following:

   tmpBmp := TBitmap.Create;
   tmpBmp.ReleaseHandle;  {don't remember the reason for this}
   tmpBmp.Handle := LoadBitmap(HInstance, 'IN_HDR');

IN_HDR is the name that I assigned that particular bitmap in the .res
file.

Hope this helps you out.  

Happy Holidays!

Jon

jonl...@atl.mindspring.com

Other Threads