473,385 Members | 1,356 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,385 software developers and data experts.

embedding a cursor in an application

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.

--
rgds, Wilfried [MapPoint MVP]
http://www.mestdagh.biz
Jan 28 '07 #1
2 1599
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.
Jan 28 '07 #2
Also realize that you can add the icon to the resource file and access it
like so:

Cursor myCursor = GetCursor(Resources.NameOfYourIconResourse);

private Cursor GetCursor(byte[] data)
{
using (MemoryStream s = new MemoryStream(data))
return new Cursor(s);
}
Dave


Jan 29 '07 #3

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

Similar topics

4
by: Alicia Haumann | last post by:
I accidentally sent this to webmaster@python.org, so this could be a duplicate if "webmaster" forwards it to this list. :{ Hi, there. Thanks for any help that can be offered. I've been...
1
by: Martin | last post by:
Greetings, I am new to python and wish to embed python in an 3D graphics application to provide application automation. The high level goal is to be able to drive my app from a script for batch...
2
by: Roose | last post by:
With some googling I have found these resources: http://docs.python.org/ext/win-dlls.html http://www.python.org/doc/faq/windows.html I have a large Win32/MFC/C/C++ application that has an...
1
by: Tommy Nordgren | last post by:
I want to write an application that embeds and extends (at least) the Python and Perl interpreters. Now i want to find as much as possible about the Python tools used for extending and embedding...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
2
by: Jim Frazer | last post by:
Hi, I'm working on an application in C# that will allow the user to create simple CAD drawings on a CEPC system. I would like to be able to change the cursor shape depending on the drawing mode...
6
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
1
by: Stefan Bellon | last post by:
Hi all! I'm embedding Python in my own C (or rather Ada, but via the C interface) program. Everything runs fine. But I have a small question regarding command history. Let's take the simplest...
0
by: Severian | last post by:
I am working on embedding Python 2.5 in my C++ application, and I have a few questions: 1) My application is multi-threaded; what problems should I be aware of if I create a separate interpreter...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.