Board index » delphi » Using bitmaps and icons in resource files

Using bitmaps and icons in resource files

Hello All,

I'm a newbie to Delphi, so please excuse me if this is in the FAQ (which I
haven't seen- is there one?)

I am quite used to using resource files with C++, but I can't find a way to
tell Delphi to use them.  I am aware of the {$R filename} compiler directive,
but once the resources are compiled in, how can I tell a BitBtn or a
Speedbutton that it's glyph can be found in the resource file?

Thanks,
Paul

--
// Paul E. Jones
// pau...@iglou.com * http://members.aol.com/paulej
// PGP public key available by e-mail or my WWW page
// "These are my opinions.  They might not be much, but they're all mine!"

 

Re:Using bitmaps and icons in resource files


Quote
Paul E. Jones wrote:
> I am quite used to using resource files with C++, but I can't find a way to
> tell Delphi to use them.  I am aware of the {$R filename} compiler directive,
> but once the resources are compiled in, how can I tell a BitBtn or a
> Speedbutton that it's glyph can be found in the resource file?

You're right in that you need the $R directive. Include
{$R yourfile.res} in your unit right after the implementation.

When you want to load the bitmap into a SpeedButton or whatever,
then use something like:

SpeedButton1.Glyph.Handle := LoadBitmap(HInstance, 'RESOURCENAME');

Ideally, you'd do this by descending from SpeedBarButton and
adding some code to the constructor to do this at creation.
--
Grant (Carpenter)
=============================================================
gr...@tiac.net               http://www.tiac.net/users/grant/
-------------------------------------------------------------

Other Threads