getting icon from embedded resource

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
 
F

farseer

solve this by placing the resource in a dll and exporting a function in
that dll that returns the handle of the icon...
 
P

Peter Proost

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
 
H

Herfried K. Wagner [MVP]

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.
 
F

farseer

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.
 
B

Bob Powell [MVP]

H

Herfried K. Wagner [MVP]

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.
 

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

Top