473,763 Members | 3,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple icons from resource

Right now i have embedded an icon file in my project with 6 different
individual icons in it. I currently use

Bitmap icon = new Bitmap(this.Get Type(), "App.ico");

to load in the icon but it will only work on the first icon. I've stumbled
upon a class called MultiIcon
(http://www.codeproject.com/dotnet/MultiIcon.asp) which allows you to select
an individual icon. My problem is how to load the resource into this class.
I've added my own constructer in which you can pass a MemoryStream (which is
what the class uses to read the Icon) but i'm unable to get my icon file into
a MemoryStream. I attempted to create a binary formatter and then serialize
it but I kept getting ArgumentNullExc eptions in mscorlib.dll. Any help on
this is greatly appreciated.
Nov 16 '05 #1
1 2530
That is a nice little class.
Change icoStream from type 'IO.MemoryStrea m' to type 'IO.Stream' and you can
use GetManifestReso urceStream().

\\\
System.Reflecti on.Assembly Assy =
this.GetType(). Assembly.GetExe cutingAssembly( );

thisIcon = new multiIcon(Assy. GetManifestReso urceStream(
"myNameSpace.Ap p.ico"))
///

The class would benefit from a ToBitmap method so that 32bit Icons look good
even when not on a Black background. Theres an example of that on my site
(which I may be able to improve on, armed with the info in this class).
http://dotnetrix.co.uk/misc.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jake Wharton" <Ja*********@di scussions.micro soft.com> wrote in message
news:F4******** *************** ***********@mic rosoft.com...
Right now i have embedded an icon file in my project with 6 different
individual icons in it. I currently use

Bitmap icon = new Bitmap(this.Get Type(), "App.ico");

to load in the icon but it will only work on the first icon. I've
stumbled
upon a class called MultiIcon
(http://www.codeproject.com/dotnet/MultiIcon.asp) which allows you to
select
an individual icon. My problem is how to load the resource into this
class.
I've added my own constructer in which you can pass a MemoryStream (which
is
what the class uses to read the Icon) but i'm unable to get my icon file
into
a MemoryStream. I attempted to create a binary formatter and then
serialize
it but I kept getting ArgumentNullExc eptions in mscorlib.dll. Any help on
this is greatly appreciated.

Nov 16 '05 #2

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

Similar topics

3
9884
by: Kyaw Soe Lin | last post by:
Dear all, I am developing a project using VB.NET. I would like to add icons in the resource file like VB6 to use with my buttons. But I can't find how to add resource file in VB.NET and how to retrieve from it. Please give me a guide how to do this. Thanks, Kyaw Soe Lin
3
2342
by: SlasherStanley | last post by:
I have wrote a c# app and included the default app.ico file and then compliled it. When I create a shortcut to the application on the destop, I would like the option of selecting from a choice of icons that are built into the file. How do I include the icons in my application for this to work? Thanks
7
3113
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
2
3445
by: SharpCoderMP | last post by:
i'm trying to embed multiple program icons in my executable. the only way so far i managed to do that is to embed native win32 resource file with multiple icons. it works, but... when i create a native win32 resource file with the VS 2005 and put there my icons, VS always converts some of the 32bit icons into 24bit - so i loose alpha blending what makes my icons look ugly. I did an experiment and created a icon file with full range of...
4
4917
by: JR | last post by:
Hi, How can I add multible icons into 1 file likeSHELL32.dll from windows it has about 50 Jan
2
1753
by: =?Utf-8?B?QXJuZQ==?= | last post by:
I am able to display an icon for my primary form. Now I need to open secondary forms. Who can I load an icon for a secondary form? -- Arne Garvander Certified Geek Professional Data Dude
3
1707
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 giving up the design time experience. jeff
1
2686
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, and at runtime I want to be able to add more icons as I need to add. I don't want to use an imagelist because that will be a set number of icons in the program.
2
4697
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 press, etc) in my form/app. I have read that I can use imageList1 and have the following: //
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9937
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,...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
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
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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.