Re: Add my own bitmaps into a resource file?
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: Sun, 16 Sep 2007 14:56:23 -0700
On 16 Sep, 21:48, "Somebody" <S...@xxxxxxxxx> wrote:
Hello,
I want to use a resource file to load my own bitmaps. Previously I have been
using loadfromfile but want to get away from that.
However, I can set up the resource file but it only appears to let me create
a new bitmap. I already have some ready but just can't see the option to add
them. Is it possible? Thanks.
I have the version 3.0 Image editor.
Create a text file with the name of the resource file you will require
(but NOT the same as your .pas file) and a .rc extension. for
example ...
SpeechMike.rc contents
SM1Pro BITMAP "..\Bitmaps\SM1Pro.bmp"
SM1ProBarcode BITMAP "..\Bitmaps\SM1ProBarCode.bmp"
SM1Classic BITMAP "..\Bitmaps\SM1Classic.bmp"
Note the file path names delimited with double quotes for long
filenames. The double quotes are not necessary for an 8.3 short
filename. Double dots mean the parent folder.
Then call BRCC32.exe as follows ...
BRCC32 /v SpeechMike.rc
This would produce a file SpeechMike.res in the same folder as
BRCC32.exe
Then place a {$R <filename> } compiler directive with the resource
file name in the implementation clause of your unit ...
{$R '..\Resources\Compiled Resources\SpeechMike.res'}
In your code declare a bitmap variable and create the bitmap in
code ...
var
FMiniBitMap : TBitmap;
begin
FMiniBitMap := TBitmap.Create;
Then load the bitmap from the resource by allocating the handle
returned from a LoadBitmap() function ...
FMiniBitmap.Handle := LoadBitmap(HInstance, 'SM1ProBarCode');
Resource access is sometimes twitchy regarding identical cases in the
resource name or type, and in the file.
You could also get at the bitmap in a resource by using a
TResourceStream.
Alan Lloyd
.
- Follow-Ups:
- Re: Add my own bitmaps into a resource file?
- From: Rudy Velthuis
- Re: Add my own bitmaps into a resource file?
- From: Kent Briggs
- Re: Add my own bitmaps into a resource file?
- References:
- Add my own bitmaps into a resource file?
- From: Somebody
- Add my own bitmaps into a resource file?
- Prev by Date: Re: Add my own bitmaps into a resource file?
- Next by Date: Re: Add my own bitmaps into a resource file?
- Previous by thread: Re: Add my own bitmaps into a resource file?
- Next by thread: Re: Add my own bitmaps into a resource file?
- Index(es):
Relevant Pages
|