473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

icons and resources

guy
i have a resource file and an icon, how do i get the icon into a resource file?
(both VS2003 and VS 2005)

guy
Dec 6 '05 #1
4 2930
Hi guy,
You can use this link.
http://www.expresscomputeronline.com...chspace2.shtml
Instead of .jpg use .ico extension with your filename.Hope it Helps.
Rakesh

Dec 6 '05 #2
guy
thanks Rakesh,
I was actually looking for a way of doing this using a designer, ideally the
ide if possible.

thanks
guy

"rakesh_nits" wrote:
Hi guy,
You can use this link.
http://www.expresscomputeronline.com...chspace2.shtml
Instead of .jpg use .ico extension with your filename.Hope it Helps.
Rakesh

Dec 6 '05 #3
guy wrote:
thanks Rakesh,
I was actually looking for a way of doing this using a designer,
ideally the ide if possible.


Binary resources are serialized and then base64 encoded before they are
put in a .resx file. You have two options.

- With the IDE you can add the icon to a form through its Icon property,
then open the .resx file as a text file, locate the entry and copy it to
the resx file where you *really* want the icon. Then you can remove the
value of the form's icon property.

- You can write some code to do this. The ResXResourceWriter will do the
serialization and encoding for you. For example, here code that will
read an icon file and write the serialised data into a .resx file:

// iconFile is the name of the .ico file
// iconName is the name of the element in the .resx file for the data
// resXName is the name of the .resx file that will be created
using (ResXResourceWriter writer = new ResXResourceWriter(resXName))
{
using(FileStream file = File.Open(iconFile, FileMode.Open))
{
Icon icon = new Icon(file);
writer.AddResource(iconName, icon);
writer.Generate(); // must do this after the last resource has been
added
}
}

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Dec 7 '05 #4
guy
thanks Rirchard
it looks a bit easier in VS2005:)

cheers

guy

"Richard Grimes" wrote:
guy wrote:
thanks Rakesh,
I was actually looking for a way of doing this using a designer,
ideally the ide if possible.


Binary resources are serialized and then base64 encoded before they are
put in a .resx file. You have two options.

- With the IDE you can add the icon to a form through its Icon property,
then open the .resx file as a text file, locate the entry and copy it to
the resx file where you *really* want the icon. Then you can remove the
value of the form's icon property.

- You can write some code to do this. The ResXResourceWriter will do the
serialization and encoding for you. For example, here code that will
read an icon file and write the serialised data into a .resx file:

// iconFile is the name of the .ico file
// iconName is the name of the element in the .resx file for the data
// resXName is the name of the .resx file that will be created
using (ResXResourceWriter writer = new ResXResourceWriter(resXName))
{
using(FileStream file = File.Open(iconFile, FileMode.Open))
{
Icon icon = new Icon(file);
writer.AddResource(iconName, icon);
writer.Generate(); // must do this after the last resource has been
added
}
}

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm

Dec 8 '05 #5

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

Similar topics

5
by: Eric | last post by:
I want to use embedded icon resources for my file type associations, but only the app.ico seems to show up when I go to choose the icons in the setup File Types editor. The same thing when I try...
1
by: marc parthoens | last post by:
We have started a c# development. We are looking for a simple way to get a collection of icons. Icons type we need: - classical windows form like exit, undo, redo, copy to clipboard, ... -...
0
by: Dave Veeneman | last post by:
I'm losing icons from a .resx file, and I'm not sure why. I'm adding the icons using ResEditor (the resource editor that ships unbuilt with VS.Net). I add the icons, save the .resx file, and all...
4
by: Andy | last post by:
I have an application (.exe) that is running in the system tray. When a message arrives: the icon in the system tray is to change so that the user knows a message has arrived. My question is: ...
3
by: QLD_AU | last post by:
Is their a way in a VB.Net application to set all sub form icons to the main form ? or even set all icons to the Application icon, without having to reference the icon as a filename ? With...
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...
3
by: Jeff Jarrell | last post by:
We are migrating a large app to .net. There are many forms and there will be many, many icons. What are some suggested techniques for more or less sharing imagelists (easy enough), BUT without...
2
by: David Veeneman | last post by:
I'm just getting started with WPF and XAML, and I am trying to create a traditional menu bar. Everything works until I get to the menu icons. I can add a bitmap icon to a menu item using this XAML...
1
by: John | last post by:
Is there such a thing as storing icons or bitmaps into a resource file, and adding more icons or bitmaps into the resource file at runtime? I want to store a bunch of icons into a resource file,...
2
by: bahnfire | last post by:
Hi, I am hoping that I finally have the right group :-) I am using Visual C++ Express 2008 and am trying to change the taskbar icon that I am using (notifyIcon1) as some state changes (button...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.