473,651 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Icon files

Lou
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding, Do I have to also add it to
an image control, I don't want the file to be part of the .resx file.
Its like VB6 when I could use load all my images from a resource file.
Lou
Nov 23 '05 #1
13 2069
"Lou" <lo********@com cast.net> schrieb:
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding, Do I have to also add it
to
an image control, I don't want the file to be part of the .resx file.
Its like VB6 when I could use load all my images from a resource file.


See:

<URL:http://groups.google.d e/group/microsoft.publi c.dotnet.langua ges.vb/msg/7f73b72ab0a8845 2>

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

Nov 23 '05 #2
> if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is "yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.

Nov 23 '05 #3
Lou
Where do I set the build Action?
"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.

Nov 23 '05 #4
Lou
Under "Solutions Items" folder I have 1 file
MyIcon.ico
There is no property to set the build action for that icon that I can find?

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.

Nov 23 '05 #5
CT
You need to add it to the project and not the solution, as it will compiled
as part of the project assembly.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"Lou" <lo********@com cast.net> wrote in message
news:eT******** *****@TK2MSFTNG P14.phx.gbl...
Under "Solutions Items" folder I have 1 file
MyIcon.ico
There is no property to set the build action for that icon that I can
find?

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an
icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource".
This
will include the .ico file in your .exe file (my direct experience is
only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.


Nov 23 '05 #6
Lou
I managed to add the icon to the proj and set its action to embedded but the
code
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))
returns null

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.

Nov 23 '05 #7
"Lou" <lo********@com cast.net> schrieb:
Under "Solutions Items" folder I have 1 file
MyIcon.ico
There is no property to set the build action for that icon that I can
find?


Add the icon to the /project/, select it in solution explorer and set the
build action in the property window.

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

Nov 23 '05 #8
Lou
This method does not seem to work or I can't get it to work?

I added an icon file to my project
I set it to "embedded resource" and added the code below in the proper
format but
it returns null.
There doesn't seem to be anything else to look for?

There must be something missing?

-Lou

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.

Nov 23 '05 #9
CT
Make sure s contains the fully namespace qualified name of the icon file,
i.e. if the name of your project is Test (assuming you didn't specify a
different namespace) and the name of the file is res.ico, then assign
"Test.res.i co" to s.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk
---------
Voodoo Programming: Things programmers do that they know shouldn't work but
they try anyway, and which sometimes actually work, such as recompiling
everything. (Karl Lehenbauer)
---------
"Lou" <lo********@com cast.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I managed to add the icon to the proj and set its action to embedded but
the code
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))
returns null

"AMercer" <AM*****@discus sions.microsoft .com> wrote in message
news:6E******** *************** ***********@mic rosoft.com...
if I add a new item (Solution Items) to my project and its an
icon(.ico),
how can I reference that file when I am coding


The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource".
This
will include the .ico file in your .exe file (my direct experience is
only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ic o".

dim s as string = "yyy.xxx.ic o" ' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Ref lection.Assembl y.GetExecutingA ssembly.GetMani festResourceStr eam(s))

Now you can set a form's icon like: someform.Icon=M yIcon.


Nov 23 '05 #10

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

Similar topics

8
2874
by: Ed Isenberg | last post by:
I notice that a lot of Web pages have an icon that is displayed preceding the URL in the place in the browser where the URL is displayed. When I bookmark or add this to Favorites the icon is also displayed at the left of the name of the page. How do I do this? I am using Frontpage 2002, but know how to edit HTML manually. Thanks,
7
7313
by: Alexander Keßler | last post by:
Hi, I asked u this morning: --------------------------------------- I want to programm some kind of Explorer like the Windows Explorer. And I want to know how can i get the same Icons/Symbols for the files and directories like the Windows Explorer uses. Example:
2
2813
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to C#. The only significant problem that I have encountered in the conversion is this one - extracting an icon from the 'KTEntryPoint' program into the software suite and placing that icon on the PC Desktop.
5
3159
by: IcingDeath via DotNetMonster.com | last post by:
I am building this SQL Server database app in which i can store files. In order to display files I want to have the app show the associated icon for the extension of the file that is in the database. Therefore the file doesnt really exist on the user's hard drive. All the file extracting techniques require that I have the actual file on the drive in order to get an icon for it. There is a workaround for this: i could create dummy files with...
2
4560
by: Dennis | last post by:
I have about 50 images in my application as "embedded resources". They are Icon size (16x16 and 24x24 and 32x32). I can use either the bitmap version or convert them to Icons. Either way seems to work ok (I make the color of the upper left pixel in the bitmap's the transparent color). I noted that the Icons take up 25k and the bitmaps only 1k). Which would be the recommended way to go, i.e., icons or bitmaps in my imagelist? Any...
3
16733
by: SveinErik | last post by:
Hi, I'm trying to find a method to save bmp, jpg and png files as ico files, 16x16 size. I have managed to convert and save bmp files to icon, but only in 32x32 size. I can't figure out how to save it in the size: 16x16, and I hope someone could help me out a bit? Code that saves from bmp to ico (32x32): private void cmdConvert_Click(object sender, EventArgs e) { string source = @"d:\image.bmp";
1
8221
by: laredotornado | last post by:
Hi, When I save out an HTML file to my desktop (I'm using Windows XP), it saves with the Firefox icon, presumably because I have Firefox as the default application to open my HTML files. Is it possible to have the desktop icon be the favicon.ico file of the web site from which I'm saving the page? Thanks, - Dave
1
2183
by: Christian Blackburn | last post by:
Hi Gang, I have come across something that I wouldn't believe unless I'd seen it with my own eyes, a DOS program with an icon. Can someone tell me how to change the icon, my company no longer has the source code for it, but we want the icon to match the rest of the suite. I know the program isn't Win16 nor Win32 and I've tried about 10 resource and or icon editors on it thus far and none work. I don't even know how Quan got the icon...
15
2046
by: Anne | last post by:
Hi, Is it possible to change the startup-icon of a .mde-file? I know I can change it in a shortcutfile, but I want it also be changed in the .mde-file. Thanks in advance
0
8345
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8693
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8456
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6156
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4143
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4279
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2694
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 we have to send another system
1
1904
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1584
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.