Link to home
Start Free TrialLog in
Avatar of UrbanPuppet
UrbanPuppet

asked on

Icons already in the EXE

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.
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

dim stream as Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("namespace.objectname")
dim i as Icon = new Icon(stream);
Avatar of UrbanPuppet
UrbanPuppet

ASKER

Stream isn't a type, so that code isn't working; how would I get it to work?
are you importing System.IO ?

what about System.Reflection for the assembly class ?

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.
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
you could just use

imports System.IO
imports System.Reflection

glad you could get it working ...

Cheers,

Greg