Board index » delphi » Load Icon from resource files

Load Icon from resource files

Does anyone know how to load an icon from a resourcefile.
With bmp's I can do
    Bmp.LoadFromResourceName(HInstance, BmpNames[Index]);

I would love to do the same with icons.

Kind regards

Alexander

 

Re:Load Icon from resource files


Quote
Alexander wrote:
> Does anyone know how to load an icon from a resourcefile.
> With bmp's I can do
>     Bmp.LoadFromResourceName(HInstance, BmpNames[Index]);

> I would love to do the same with icons.

Use the LoadIcon API function.

procedure TForm1.Button1Click(Sender: TObject);
var
 Icon: TIcon;
begin
 Icon := TIcon.Create;

 Icon.Handle := LoadIcon(HInstance, 'MAINICON');

 {check success by viewing}
 Image1.Picture.Assign(Icon);

 Icon.Free;
end;

Re:Load Icon from resource files


Thanks Mauro,

I'll try it out right now;

kind regards
Alexander

Quote
"Mauro Patino" <M-Pat...@govst.edu> wrote in message

news:3B2E1328.6E9F686D@govst.edu...
Quote
> Alexander wrote:

> > Does anyone know how to load an icon from a resourcefile.
> > With bmp's I can do
> >     Bmp.LoadFromResourceName(HInstance, BmpNames[Index]);

> > I would love to do the same with icons.

> Use the LoadIcon API function.

> procedure TForm1.Button1Click(Sender: TObject);
> var
>  Icon: TIcon;
> begin
>  Icon := TIcon.Create;

>  Icon.Handle := LoadIcon(HInstance, 'MAINICON');

>  {check success by viewing}
>  Image1.Picture.Assign(Icon);

>  Icon.Free;
> end;

Other Threads