473,473 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

embed and use icons

What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those in
the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture of
how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.
Nov 16 '05 #1
7 4283
Your icons should be included in your project and their Build Action should
be Embedded. With this configuration, it will be included in your assembly
(of your project) , be it a referenced class library (.dll) or your main
application (.exe). From code, you have to use ResourceManager,
particularly the ResourceReader to obtain the said icon from the assembly.

hth

"axis" <no**@none.com> wrote in message
news:Ntggd.18698$HA.9308@attbi_s01...
What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those in the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture of how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.

Nov 16 '05 #2
I apologize for being thick about this... I keep reading the docs for the
classes and can't make any progress with it. As far as I've determined, my
code should look something like this:

ResourceManager rm = new
ResourceManager("???",Assembly.GetExecutingAssembl y());
Icon theIcon = (Icon)rm.GetObject("IconName.ico");

So what goes in the part that says ??? . Lets say project is called
TestProject, and the form in question is Form1. I noticed in obj there was a
file called TestProject.Form1.resources, so I've tried putting
"TestProject.Form1.resources" where the questionmarks are, and the code goes
through, but the next line doesn't retrieve the icon.

Any tips would be appreciated.

"joeycalisay" <hcalisay@_spamkiller_codex-systems.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Your icons should be included in your project and their Build Action
should
be Embedded. With this configuration, it will be included in your
assembly
(of your project) , be it a referenced class library (.dll) or your main
application (.exe). From code, you have to use ResourceManager,
particularly the ResourceReader to obtain the said icon from the assembly.

hth

"axis" <no**@none.com> wrote in message
news:Ntggd.18698$HA.9308@attbi_s01...
What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those

in
the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture

of
how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.


Nov 16 '05 #3
SP
"axis" <no**@none.com> wrote in message
news:Ntggd.18698$HA.9308@attbi_s01...
What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those
in the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture
of how to do it. Documentation talks about ResourceManagers and other
stuff, but as far as I can tell it talks about creating a dll, not in the
executable itself.


The following should set get you going. This example is with PNG files set
as Embedded Resources. You will need to modify it to work with icons.

string[] res = Assembly.GetExecutingAssembly().GetManifestResourc eNames();
foreach(string s in res)
{
Stream stream =
Assembly.GetExecutingAssembly().GetManifestResourc eStream(s);
Image image = Image.FromStream(stream);
}
Nov 16 '05 #4
axis wrote:

What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those in
the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture of
how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.


Took me forever to figure it out as well. I've gotta tell you, the .NET docs
pretty much suck. All the examples seem to be generally the same thing, and do
a lousy job of demonstrating what is actually needed.

Forget all the resource manager junk, streams, etc. It all comes down to (from
within your form):

Icon icon = new Icon(GetType(), "myIcon.ico");

The GetType() is the easiest way to get the assembly for your exe, when calling
from within your form.

Other notes: if you store your icons in a subfolder, you will need to prefix
the icon name w/ the subfolder + ".", such as "Icons.myIcon.ico", presuming
they are stored in a subfolder called "Icons" off of your main project folder.

Lastly, make sure that your icon build action is set to "Embedded Resource"
(icon properties, Build Action).
Nov 16 '05 #5
Have you tried ImageList class????

Maqsood Ahmed
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6

"Julie" <ju***@nospam.com> wrote in message
news:41***************@nospam.com...
axis wrote:

What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those
in
the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture
of
how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.


Took me forever to figure it out as well. I've gotta tell you, the .NET
docs
pretty much suck. All the examples seem to be generally the same thing,
and do
a lousy job of demonstrating what is actually needed.

Forget all the resource manager junk, streams, etc. It all comes down to
(from
within your form):

Icon icon = new Icon(GetType(), "myIcon.ico");

The GetType() is the easiest way to get the assembly for your exe, when
calling
from within your form.

Other notes: if you store your icons in a subfolder, you will need to
prefix
the icon name w/ the subfolder + ".", such as "Icons.myIcon.ico",
presuming
they are stored in a subfolder called "Icons" off of your main project
folder.

Lastly, make sure that your icon build action is set to "Embedded
Resource"
(icon properties, Build Action).


That worked! Thank you so much.
Nov 16 '05 #7
hi
check this link .
i think this will solve the proble
http://msdn.microsoft.com/communitie...fc4&sloc=en-us

regards
Ansil
Dimensions
Technopark
Trivandrum
an****@gmail.com

"axis" wrote:
I apologize for being thick about this... I keep reading the docs for the
classes and can't make any progress with it. As far as I've determined, my
code should look something like this:

ResourceManager rm = new
ResourceManager("???",Assembly.GetExecutingAssembl y());
Icon theIcon = (Icon)rm.GetObject("IconName.ico");

So what goes in the part that says ??? . Lets say project is called
TestProject, and the form in question is Form1. I noticed in obj there was a
file called TestProject.Form1.resources, so I've tried putting
"TestProject.Form1.resources" where the questionmarks are, and the code goes
through, but the next line doesn't retrieve the icon.

Any tips would be appreciated.

"joeycalisay" <hcalisay@_spamkiller_codex-systems.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Your icons should be included in your project and their Build Action
should
be Embedded. With this configuration, it will be included in your
assembly
(of your project) , be it a referenced class library (.dll) or your main
application (.exe). From code, you have to use ResourceManager,
particularly the ResourceReader to obtain the said icon from the assembly.

hth

"axis" <no**@none.com> wrote in message
news:Ntggd.18698$HA.9308@attbi_s01...
What I want to do is pretty simple: I have a bunch of icons in my
application project (visual studio .net 2003), and I want to embed those

in
the executable, and access them through code.

I've spent an hour browsing MSDN, and I still don't have a clear picture

of
how to do it. Documentation talks about ResourceManagers and other stuff,
but as far as I can tell it talks about creating a dll, not in the
executable itself.

Thanks in advance.



Nov 16 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: drum118 | last post by:
Has anyone experience problems with firewall blocking some icons and not others. I am using Zone alarm and have the popup set for medium and it was blocking some of the icons for some strange...
24
by: Crom | last post by:
Ok. I want to settle this once and for all. After looking at the source for various, rather sizeable (but not all were so big) web sites that use icons that show up in the addressbar beside the...
3
by: sto | last post by:
look at this picture http://upload.cs99.net/e.gif i use the function SHGetFileInfo to get file icons. but these icons are not very nice. there are some black things round of the icons. many...
8
by: Shane Story | last post by:
I would like to embed mutiple icons inside my main exe file so that they can be viewed like Shell32.dll or whatever. Can't figure out how to do this. Sorry if this is in the wrong group. ...
6
by: B-Dog | last post by:
Does anyone know where I can find some professional looking icons that are the standard windows collection for developers? The ones that came on the VS cd are pretty lame. Thanks
17
by: Brett | last post by:
I'd like references on where to find some good (quality) icons to use for form and application icons (for the EXE). Most of the free stuff isn't that great looking and there isn't a good...
3
by: Pucca | last post by:
HI, I'm using vs2005. There are very few icons I found in the folder of vs2005imagelibrary under the install folder of vs2005. Does anyone know where I can download icons that are typically used...
1
by: Jon Slaughter | last post by:
I'm trying to create a windows explorer like app and the problem I'm having is getting the proper icon for the folders and items. In windows explorer there are many different icons and most seem...
4
by: Sanoski | last post by:
This might be a dumb question. I don't know. I'm new to all this. How do you find icons for your programs? All GUI applications have cool icons that represent various things. For instance, to save...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.