Board index » delphi » Can't load icon from resource file

Can't load icon from resource file

Hi.
I'm trying to use an icon from a resource file, but it doesn't works.
Where is the possible error?
The code:

...
type
  TfrmBASE = class(TForm)
...
implementation

{$R *.DFM}
{$R ICONS.RES}
...
procedure TfrmBASE.FormCreate(Sender: TObject);
begin
  //Application.Icon.LoadFromFile('TEG.ico'); <-- Works, of course
  Application.Icon.Handle:= LoadIcon(HInstance, 'TEGICO'); // <--Doesn't
work!
end;

BTW, opening the icons.res file in different resource editors shows the
resource TEGICO of ICON kind.
I'm using D3.

Thanks in advance,

Alvaro Paiva {*word*73}
apai...@cantv.net

 

Re:Can't load icon from resource file


On Mon, 08 Nov 1999 08:53:45 -0400, Alvaro Paiva {*word*73}

Quote
<apai...@cantv.net> wrote:
>Hi.
>I'm trying to use an icon from a resource file, but it doesn't works.
>Where is the possible error?

Your code looks fine.  Make sure that you use CAPITAL letters
everywhere in naming the icon.  Also, ensure that the icon is indeed
being compiled into the application.  You can use the RESEXPLR demo
application to do that.  It can also show you the way to load an icon.

Nick Hodges
TeamB

Re:Can't load icon from resource file


Hi.
Thank you very much Nick.

The problem was in the .res file, there was some lines of comments
generated by the freeware program i was using to convert images into .rc
files (image2rc). I delete the comments and now it works.

Alvaro Paiva {*word*73}.
apai...@cantv.net

Other Threads