Loading Resource Icons using LoadIcon from coredll.dll

  • Thread starter Thread starter Pat
  • Start date Start date
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)
 
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.
 
Back
Top