Loading Resource Icons using LoadIcon from coredll.dll

P

Pat

Does anyone know how to load an icon (that is a resource in my
project) using the LoadIcon function from coredll.dll? I can load the
application icon using the value #32512 as the second parameter, but I
would like to be able to load different icons for use with
Shell_NotifyIcon().

Thanks for any help.

Pat
(e-mail address removed)
 
G

Guest

I use the following method:
- Add the icon to your project and set the 'Build Action' to 'Embedded
Resource'
- Use the following code:

System.IO.Stream stream =
assembly.GetManifestResourceStream("NameSpace.Name.Ico);
if (null == stream)
return false;

Icon icon = new Icon(stream);
if (null == icon)
return false;

imageList.Images.Add(icon);
stream.Close();

Here you have to replace the 'Namespace' with the name of your NameSpace and
'Name.Ico' with the name of the Icon in your project.

Note: this does not work with 32-bit color dept icons. To get an acceptable
size I use only 256 color icons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top