getting icon from embedded resource

  • Thread starter Thread starter farseer
  • Start date Start date
F

farseer

Hi,
I created a new resouce ("app.resx") in my project and added an icon to
this resource with name "IL_ICON". I would like to use this resource
in some unmanaged code, in particular, with the api function
SHNotificationAdd. How can i do this?
i have tried using ResourceManager to get that icon, but i am getting
back NULL. Even if i did get back an icon, how can i use this to with
the hIcon parameter of SHNotificationAdd?

thank you much
 
solve this by placing the resource in a dll and exporting a function in
that dll that returns the handle of the icon...
 
Hi this is a way of getting an Icon from an embedded resource, but don't
forget to set the ico's build action to embedded resource.

Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Dim ic As Icon
ic = New System.Drawing.Icon(p.GetManifestResourceStream(Me.GetType(),
"141_7.ico"))

hth

Greetz Peter
 
I created a new resouce ("app.resx") in my project and added an icon to
this resource with name "IL_ICON". I would like to use this resource
in some unmanaged code, in particular, with the api function
SHNotificationAdd. How can i do this?
i have tried using ResourceManager to get that icon, but i am getting
back NULL. Even if i did get back an icon, how can i use this to with
the hIcon parameter of SHNotificationAdd?

Add the icon file to your project and set its 'Build Action' property to
'Embedded Resource'. You can use the code below to load the icon at
runtime:

\\\
foo.Icon = _
New Icon( _
[Assembly].GetExecutingAssembly().GetManifestResourceStream( _
"WindowsApplication1.Ball.ico" _
) _
)
///

'WindowsApplication1' is the root namespace of the application, "Ball.ico"
is the icon's filename. You can determine the icon's handle using its
'Handle' property.
 
thank you for the response. i will try this. however, my issue is
getting a pointer to the icon in C# that can be used with
SHNotificationAdd. i have been able to get around this by including
the icon as a resource in a dll, and then exporting a function that
returns that icon pointer from that dll.
 
however, my issue is
getting a pointer to the icon in C# that can be used with
SHNotificationAdd.

As said previously, using the icon object's 'Handle' property should work.
 
Back
Top