By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

getting icon from embedded resource

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


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

Nov 21 '05 #2

P: n/a
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

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

<fa*****@optonline.net> schreef in bericht
news:11**********************@g43g2000cwa.googlegr oups.com...
solve this by placing the resource in a dll and exporting a function in
that dll that returns the handle of the icon...

Nov 21 '05 #3

P: n/a
<fa*****@optonline.net> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

P: n/a
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.

Nov 21 '05 #5

P: n/a
See my reply to your identical question in the C# group.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<fa*****@optonline.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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.

Nov 21 '05 #6

P: n/a
<fa*****@optonline.net> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.