Link to home
Start Free TrialLog in
Avatar of frdep
frdep

asked on

Load an Icon from a RES file


Hi,
How can I load an Icon from a .res file ?
I did this, but it do not work :


Var c : TIcon ;

  c := TIcon.Create ;
  c.Handle := LoadIcon(hInstance,'HOPY');
  FImageList.AddIcon(c) ;

Thanks
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

did you include the .res file into your programme? {$R myIcon.res}
ASKER CERTIFIED SOLUTION
Avatar of tongalite
tongalite

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of frdep
frdep

ASKER


Thanks.

I have a problem.  How can I have icon transparent ?  I load icon into a TImageList, wich is linked to a toolbar.

I insert this line :
{ Image is a TImage }
Image := TImage.Create(Self) ;
Image.Picture.Icon.Transparent := True ;
...
but it is not working
Thanks again.
Hi,
You may find something here to help you
BTW... You can use Delphi Image editor to create icon resources and select the tranparent color in the editor.
Good luck
T.
------------------------------------------


From Learn Delphi 4 in 21 days
http://www.cesis.lv/learn/delphi/ch11.htm
Transparent and Inverted Colors
In the case of icons and cursors, you can also choose the transparent color (the word color being relative here). When you use the transparent color, the background beneath the icon shows through wherever the transparent color is used. That could mean the Windows background in the case of a shortcut, or it could mean the title bar of your application.

Whether you use the transparent color depends on your personal tastes and the particular icon you are creating. In the case of cursors, you will almost always use the transparent color as the background for the icon. Rarely do you have a cursor that appears as a solid block.

Choosing the inverted color causes the background underneath the icon to be inverted (like reverse video). Use of the inverted color isn't common, but it is there if and when you need it.

Both the transparent and inverted colors are shown next to the color palette when editing icons and cursors. They are represented by color squares with a curved line running through them.