Board index » delphi » Help: Icon resources in a .DLL ?

Help: Icon resources in a .DLL ?

Hi -

I'm writing a .DLL in Delphi, and I need to be able to have an
ICON resource in the file, and I need to be able to load it. I
can't find a way to do this (and dumping the compiled .DLL shows
that it contains no icons at all).

Ideas?

// Nigel

ni...@compsoc.man.ac.uk

 

Re:Help: Icon resources in a .DLL ?


Quote
ni...@mrbounce.compsoc.man.ac.uk (Nigel Magnay) wrote:
>I'm writing a .DLL in Delphi, and I need to be able to have an
>ICON resource in the file, and I need to be able to load it. I
>can't find a way to do this (and dumping the compiled .DLL shows
>that it contains no icons at all).

Create your icons as you normally would, save them as .ICO files.

Now, create a resource file (text file) with your favorite editor,
called "MYICONS.RC":

        ICON_1   ICON  ICON1.ICO
        ICON_2   ICON  ICON2.ICO

It's just a list in the form
        <Name of Icon> ICON  <file name of Icon>

Then, compile this MYICONS.RC using the Borland Resource Compiler:
        BRCC MYICONS.RC

You now have a MYICONS.RES. Include this in your sample application:
        {$R MYICONS.RES}

You can now create a TIcon object in Delphi and load it from the
resource which is included in your EXE file:

        MyFirstIcon := TIcon.Create;
        MyFirstIcon.Handle := LoadIcon (nil, 'ICON_1');

This should do the trick.

Hope this helps
Marc

======================================================================
[ Marc Scheuner, marc.scheu...@berner.ch  CH-3001 BERNE, Switzerland ]
======================================================================

Other Threads