473,702 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

So nobody knows how to make a custom mouse cursor, eh?

I've now asked how three times in this forum with no answers. So I went to
the 'windowsforms' newsgroup, and found this post, also unanswered, with the
same problem:

"Hello,

I've tried to find something on this in the newsgroups but came up with
nada:

I'm trying to create a custom cursor in VS2005. I have a .cur file
that I have put in my "Resources" folder. The resource manager does
not recognize the .cur extension and puts it under the generic "Files"
category (vs. "Images", "Icons", "Strings", etc.)

When I try to refer to the cursor, like:
Properties.Reso urces.arrowTran s, apparently it comes out to a byte[].
How can I convert this into a Cursor object?

I used to have code in 2003 that used the GetManifestReso urceStream
method, but that doesn't work. And how does the
"BaseApplicatio nManifest" option work in the "Build Action" item (vs.
"None", "Embedded Resource", "Compile", and "Content") in the file
Properties window?

Thanks,
Jon"

And nobody has responded to him for the last MONTH. I just recently posted
almost the exact same question today, so I guess I'm out of luck until at
least next year to find out how to do this...lol

So I guess nobody knows how to use.CUR files or make a custom cursor form a
bitmap. Don't feel too bad. Neither does MSDN2, as their example doesn't
work...

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]
Dec 16 '05 #1
6 5048
W
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I've now asked how three times in this forum with no answers. So I went to
the 'windowsforms' newsgroup, and found this post, also unanswered, with
the same problem:

"Hello,

I've tried to find something on this in the newsgroups but came up with
nada:

I'm trying to create a custom cursor in VS2005. I have a .cur file
that I have put in my "Resources" folder. The resource manager does
not recognize the .cur extension and puts it under the generic "Files"
category (vs. "Images", "Icons", "Strings", etc.)

When I try to refer to the cursor, like:
Properties.Reso urces.arrowTran s, apparently it comes out to a byte[].
How can I convert this into a Cursor object?

I used to have code in 2003 that used the GetManifestReso urceStream
method, but that doesn't work. And how does the
"BaseApplicatio nManifest" option work in the "Build Action" item (vs.
"None", "Embedded Resource", "Compile", and "Content") in the file
Properties window?

Thanks,
Jon"

And nobody has responded to him for the last MONTH. I just recently posted
almost the exact same question today, so I guess I'm out of luck until at
least next year to find out how to do this...lol

So I guess nobody knows how to use.CUR files or make a custom cursor form
a bitmap. Don't feel too bad. Neither does MSDN2, as their example doesn't
work...

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]


Supposed your cursor file is named MyCursor.cur, you'll have to build the
sample

cl /clr msdn2sample.cpp /link
/assemblyresourc e:MyCursor.Cur, CustomCursor.My Cursor.Cur

Willy.
Dec 16 '05 #2

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]


Just realized I could better post the complete sample.

// command line build:
// cl /clr ccursor.cpp /link
/assemblyresourc e:Cursor1.Cur,C ustomCursor.Cur sor1.Cur

#using "System.dll "
#using "System.drawing .dll"
#using "System.Windows .Forms.dll"
using namespace System;
using namespace System::Drawing ;
using namespace System::Windows ::Forms;

namespace CustomCursor
{
public ref class Form1: public System::Windows ::Forms::Form
{
public:
Form1()
{
this->ClientSize = System::Drawing ::Size( 292, 266 );
this->Text = "Cursor Example";
this->Cursor = gcnew System::Windows ::Forms::Cursor (
GetType(),"Curs or1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Ru n( gcnew CustomCursor::F orm1 );
}

Willy.
Dec 16 '05 #3
The code you listed is verbatim the code sample provided by MS on their
webpage I gave a link to that I've tested and doesn't work (at least for me
it doesn't):

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

Have you tried the code? Does it work for you (note: it compiles just fine,
but it doesn't run just fine (null exception error)...

[==P==]

"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]


Just realized I could better post the complete sample.

// command line build:
// cl /clr ccursor.cpp /link
/assemblyresourc e:Cursor1.Cur,C ustomCursor.Cur sor1.Cur

#using "System.dll "
#using "System.drawing .dll"
#using "System.Windows .Forms.dll"
using namespace System;
using namespace System::Drawing ;
using namespace System::Windows ::Forms;

namespace CustomCursor
{
public ref class Form1: public System::Windows ::Forms::Form
{
public:
Form1()
{
this->ClientSize = System::Drawing ::Size( 292, 266 );
this->Text = "Cursor Example";
this->Cursor = gcnew System::Windows ::Forms::Cursor (
GetType(),"Curs or1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Ru n( gcnew CustomCursor::F orm1 );
}

Willy.

Dec 16 '05 #4
I know of two ways to get the thing working:

1. Have an icon named Cursor1.Cur
2. Use linker option /ASSEMBLYRESOURC E:"Cursor1.Cu r"
3. Use the following line to get at the cursor:

gcnew
System::Windows ::Forms::Cursor (System::Reflec tion::Assembly: :GetExecutingAs sembly()->GetManifestRes ourceStream("Cu rsor1.Cur"));

The other way:
1. Have an icon named CustomCursor.Cu rsor1.Cur
2. Use linker option /ASSEMBLYRESOURC E:"CustomCursor .Cursor1.Cur"
3. Use the following line to get at the cursor (assuming AnyClass is in the
namespace CustomCursor):

gcnew System::Windows ::Forms::Cursor (AnyClass::type id, "Cursor1.Cu r");

Hope this helps.

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:ut******** *****@TK2MSFTNG P15.phx.gbl...
The code you listed is verbatim the code sample provided by MS on their
webpage I gave a link to that I've tested and doesn't work (at least for
me it doesn't):

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

Have you tried the code? Does it work for you (note: it compiles just
fine, but it doesn't run just fine (null exception error)...

[==P==]

"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]


Just realized I could better post the complete sample.

// command line build:
// cl /clr ccursor.cpp /link
/assemblyresourc e:Cursor1.Cur,C ustomCursor.Cur sor1.Cur

#using "System.dll "
#using "System.drawing .dll"
#using "System.Windows .Forms.dll"
using namespace System;
using namespace System::Drawing ;
using namespace System::Windows ::Forms;

namespace CustomCursor
{
public ref class Form1: public System::Windows ::Forms::Form
{
public:
Form1()
{
this->ClientSize = System::Drawing ::Size( 292, 266 );
this->Text = "Cursor Example";
this->Cursor = gcnew System::Windows ::Forms::Cursor (
GetType(),"Curs or1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Ru n( gcnew CustomCursor::F orm1 );
}

Willy.


Dec 16 '05 #5
Sure I did, question is, did you run the command line compile command as
included in the snip?

cl /clr ccursor.cpp /link
/assemblyresourc e:Cursor1.Cur,C ustomCursor.Cur sor1.Cur

Note the /assemblyresourc e linker option, you need to substitute your cursor
file name with the Cursor1.cur name in the above command.
The sole problem with the msdn2 samples is that the description of the
resource embedding is only valid for C#, not for the other language samples.

Willy.

Willy.
"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:ut******** *****@TK2MSFTNG P15.phx.gbl...
The code you listed is verbatim the code sample provided by MS on their
webpage I gave a link to that I've tested and doesn't work (at least for
me it doesn't):

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

Have you tried the code? Does it work for you (note: it compiles just
fine, but it doesn't run just fine (null exception error)...

[==P==]

"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .

"Peter Oliphant" <po*******@Roun dTripInc.com> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..

http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx

So I guess MS itself is keeping this a secret. Oh goody! : )

[==P==]


Just realized I could better post the complete sample.

// command line build:
// cl /clr ccursor.cpp /link
/assemblyresourc e:Cursor1.Cur,C ustomCursor.Cur sor1.Cur

#using "System.dll "
#using "System.drawing .dll"
#using "System.Windows .Forms.dll"
using namespace System;
using namespace System::Drawing ;
using namespace System::Windows ::Forms;

namespace CustomCursor
{
public ref class Form1: public System::Windows ::Forms::Form
{
public:
Form1()
{
this->ClientSize = System::Drawing ::Size( 292, 266 );
this->Text = "Cursor Example";
this->Cursor = gcnew System::Windows ::Forms::Cursor (
GetType(),"Curs or1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Ru n( gcnew CustomCursor::F orm1 );
}

Willy.


Dec 17 '05 #6

Hi, I am not sure if you ever got an appropriate response to your
question, so I will tell you what I did.

I could not get this working by adding the cursor to the Resources in
VS 2005.

What I did was I added and 'Images' folder to the project.
I then put m cursors in this folder.
Then I set the Build Action property of each cursor to embeded
resource.

The if you look at the properties for the project, under 'Application'
you will see what the 'Default namespace:' is.

Now to load the embeded resource cursor, you would do this...

Cursor m_BurnCursor = new
Cursor(Assembly .GetExecutingAs sembly().GetMan ifestResourceSt ream("MyProject Namespace.Image s.MyCursor.cur" ));

Where MyProjectNamesp ace is replaced by the default namespace found
above for the project and MyCursor.cur is replaced by the name of your
curesor.

I noticed in the MSDN2 page the was mentioned in the responses to your
question it says that the Cursor class does not support Animated and
any cursor that is not black and white. I have never tried animated,
but color did work for me.

I hope this helps.

I hope this helps in some way.

--
Wendelldh
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jun 5 '06 #7

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

Similar topics

3
17308
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting seems to be ignored completely, even when I try with window.setTimeout. So my two questions are: (1) Most important: Is there anything I can do so that I don't have to wait for the next mouse event before the cursor gets repainted. (2) Why...
2
4612
by: Tom Alcendor | last post by:
I am building a chess game application that allows a user to click on a piece and move it to a new square. When the user clicks on a piece the mouse pointer must change to the image associated with that square. The squares are PictureBoxes with images of the pieces set to the pBox's image property. I am having trouble with changing the mouse pointer to a custom mouse pointer during drag and drop operations. I have checked several...
3
6904
by: Simon Wigzell | last post by:
I have an image with several links in it in mapped areas. I am using a custom cursor on the page and would like to have a custom cursor appear on mouse over of the mapped links. Something like: This works for the body, font or img tag: <body style="cursor: url('cursor2.cur')"> <font style="cursor: url('cursor1.cur')">Text</font> <img style="cursor: url('cursor1.cur')" src="...etc...">
2
2419
by: Brad | last post by:
Hi all, newbie here. I'm currently designing a custom splitter control... When the mouse hovers over a certain area on my splitter I need to be able to display a custom cursor that I've designed. I've tried several ways to assign my custom cursor to a cursor variable, the most obvious being by the filename: myCursor = new Cursor("c:\\myCursor.cur"); and then assign it as the current cursor when in position: Cursor.current = myCursor
15
10941
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works great. But I now want to show a different tooltip for every day. For now I found out that I can add a tooltip for the entire custom control
1
3921
by: Tim | last post by:
Hi, I would like to create a custom mouse cursor for my print preview page. I want to use a bitmap of a magnifiying glass with a plus in it. Pretty standard stuff. How do I change the cursor? I found the code below but I just get the default mouse cursor dragging around the bitmap which is actually a little behind. I want to replace the
0
1341
by: Andy Wynn | last post by:
Hello All, I've got a custom control ( Panel-like, but not inheriting from Panel) that has a header region that's custom drawn. Custom Control is using a custom controldesigner class that inherits from ParentControlDesigner. Just for starters I wanted to try to change the mouse cursor if it fell
4
6972
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I just gotta fix it. I need to make some calculations on the measurements and VB6 is my language. Yes, the system mouse will corrupt the measurement, but it's an auditing function and that's acceptable.
0
1568
vekipeki
by: vekipeki | last post by:
Does anyone know if there is a way to set a custom mouse cursor for an ActiveX control in .Net? I am adding some mouse functionality to an existing ActiveX control, and would like to change the cursor shape according to the current state. It's a Windows Forms app, with an ActiveX control wrapped in the (automatically generated) class (derived from AxHost). Although AxHost is derived from Windows.Forms.Control, the public Cursor property does...
0
8739
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9089
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7831
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
6575
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
5907
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4412
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3107
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
2
2402
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2036
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.