Found it. This was not so evident to find, so I wants to share:
- Add existing item to project and select the icon file
- Select the file in solution explorer, click right: properties
- Set Build action to: Embedded resource
Then you can get it a runtime with folowing code fragment. The trick is
that the namespace must be included in the name, and the whole thing
seems case sensitive:
using System.IO;
using System.Reflection;
Stream s =
Assembly.GetExecutingAssembly().GetManifestResourc eStream("WindowsApplication2.NE.ico");
bmp = new Bitmap(s);
Cursor = new Cursor(bmp.GetHicon());
--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Wilfried Mestdagh wrote:
Hi,
I create a new cursor like this:
Bitmap bmp = new Bitmap(fileName);
panel1.Cursor = new Cursor(bmp.GetHicon());
But now I want to embed the image in the executable. I have already add
the *.ICO file to the project, but how to access it in code ?
I'm using VS2005 SP1.