Board index » delphi » Including a .bmp file in my .exe file

Including a .bmp file in my .exe file

I've been trying to include a .BMP file with my app.

I created a .rc file using:

MyPicture  BMP   Picture.bmp

This was compiled with brcc32 and I obtained MyPicture.res, which appears to
be the correct size, and there were no error messages.

Then I placed {$R MyPicture.res}  in the main form file.  Now, when I
compile the app, it is much larger, by the size of the .res file.  All seems
good.

However, I don't know how to "read" the .bmp file.  I would have thought
that

MyBitmap.LoadFromResourceName(HInstance, 'MyPicture');

would work.  Obviously I have the syntax wrong, and can't find anything in
the .HLP system.  What is "HInstance"? (I just copied this directly from my
DDJ example).

HELP :)

 

Re:Including a .bmp file in my .exe file


Bob,
  Everything seems to right, with the possible exception of not quotibg the
name of the resource file(but I think that the compiler is smart enough to
ignore that). Do you want to send me the RES file and try it out here?

-Dave
Good Luck!!
    -Dave
Inprise Certified Delphi 4 Client/Server developer
http://www.erols.com/dparsons

Quote
Bob Richardson wrote in message <7aherp$e5...@remarQ.com>...
>I've been trying to include a .BMP file with my app.

>I created a .rc file using:

>MyPicture  BMP   Picture.bmp

>This was compiled with brcc32 and I obtained MyPicture.res, which appears
to
>be the correct size, and there were no error messages.

>Then I placed {$R MyPicture.res}  in the main form file.  Now, when I
>compile the app, it is much larger, by the size of the .res file.  All
seems
>good.

>However, I don't know how to "read" the .bmp file.  I would have thought
>that

>MyBitmap.LoadFromResourceName(HInstance, 'MyPicture');

>would work.  Obviously I have the syntax wrong, and can't find anything in
>the .HLP system.  What is "HInstance"? (I just copied this directly from my
>DDJ example).

>HELP :)

Re:Including a .bmp file in my .exe file


In article <7aherp$e5...@remarQ.com>, "Bob Richardson" <ple...@dontspam.com>
writes:

Quote
>I've been trying to include a .BMP file with my app.

>I created a .rc file using:

>MyPicture  BMP   Picture.bmp

<snip>

Quote
>However, I don't know how to "read" the .bmp file.  I would have thought
>that

>MyBitmap.LoadFromResourceName(HInstance, 'MyPicture');

>would work.  Obviously I have the syntax wrong, and can't find anything
> in the .HLP system.  What is "HInstance"? (I just copied this directly
> from my DDJ example).

You should use RT_BITMAP as the resource type (look in Graphics.PAS in the
LoadFromResourceName() function).

If you are using the WinAPI calls of FindResource / LoadResource you can use
any name you wish for the resource type because you specify it in these calls.
But using Derlphi's higher level calls, Delphi assumes certain type names
(usually starting with RT_).

HInstance is the instance handle of the application and is a global Delphi
variable filled by Delphi with the appropriate Win API value.

Alan Lloyd
alangll...@aol.com

Other Threads