Solved

Icons already in the EXE

Posted on 2004-08-07
8
359 Views
Last Modified: 2010-04-23
In the project properties, I set my application's default icon which, in turn, added it to the resources or whatever you want to call it.. it's compiled in with the exe.. I plan on doing this with all my icons but I need to know how to get the icons in the form of System.Drawing.Icon so they can be accepted in most controls. Thanks in advance.
0
Comment
Question by:UrbanPuppet
  • 5
  • 3
8 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11745107
dim stream as Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("namespace.objectname")
dim i as Icon = new Icon(stream);
0
 

Author Comment

by:UrbanPuppet
ID: 11745136
Stream isn't a type, so that code isn't working; how would I get it to work?
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11745150
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11745154
are you importing System.IO ?

what about System.Reflection for the assembly class ?

0
 

Author Comment

by:UrbanPuppet
ID: 11745176
Ok, sorry, did that and now it's almost working, I just don't know what to put for namespace.objectname .. the project is called XSM and the icon is called icoMain.ico but XSM.icoMain.ico didn't work. I've raised the points a little too.
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 150 total points
ID: 11745185
What is the default namespace for your project ?

Also it is case sensitive ...

http://www.dotnetspider.com/Technology/KBPages/442.aspx gives further examples of using GetManifestResourceStream.
0
 

Author Comment

by:UrbanPuppet
ID: 11745210
OK, thanks, that link helped a lot.. But i had after I tinkered with your first post.. I just needed to change the icon to an embedded resource..

The final code ended up like this:

Dim Stream As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("XSM.icoMain.ico")
Dim i As Icon = New Icon(Stream)

frmMain.Icon = i
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11745216
you could just use

imports System.IO
imports System.Reflection

glad you could get it working ...

Cheers,

Greg
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET (2008) - Refactoring Question 2 23
VB.net Move a class from Solution Items to a project 2 32
VB.net Open Folder in Windows Explorer 3 51
Code enhancement 4 20
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question