473,326 Members | 2,114 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,326 software developers and data experts.

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.Resources.arrowTrans, 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 GetManifestResourceStream
method, but that doesn't work. And how does the
"BaseApplicationManifest" 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 5032
W
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP14.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.Resources.arrowTrans, 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 GetManifestResourceStream
method, but that doesn't work. And how does the
"BaseApplicationManifest" 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
/assemblyresource:MyCursor.Cur,CustomCursor.MyCurso r.Cur

Willy.
Dec 16 '05 #2

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP14.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
/assemblyresource:Cursor1.Cur,CustomCursor.Cursor1. 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(),"Cursor1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Run( gcnew CustomCursor::Form1 );
}

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***************@TK2MSFTNGP09.phx.gbl...

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP14.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
/assemblyresource:Cursor1.Cur,CustomCursor.Cursor1. 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(),"Cursor1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Run( gcnew CustomCursor::Form1 );
}

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 /ASSEMBLYRESOURCE:"Cursor1.Cur"
3. Use the following line to get at the cursor:

gcnew
System::Windows::Forms::Cursor(System::Reflection: :Assembly::GetExecutingAssembly()->GetManifestResourceStream("Cursor1.Cur"));

The other way:
1. Have an icon named CustomCursor.Cursor1.Cur
2. Use linker option /ASSEMBLYRESOURCE:"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::typeid, "Cursor1.Cur");

Hope this helps.

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:ut*************@TK2MSFTNGP15.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***************@TK2MSFTNGP09.phx.gbl...

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP14.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
/assemblyresource:Cursor1.Cur,CustomCursor.Cursor1. 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(),"Cursor1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Run( gcnew CustomCursor::Form1 );
}

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
/assemblyresource:Cursor1.Cur,CustomCursor.Cursor1. Cur

Note the /assemblyresource 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*******@RoundTripInc.com> wrote in message
news:ut*************@TK2MSFTNGP15.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***************@TK2MSFTNGP09.phx.gbl...

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP14.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
/assemblyresource:Cursor1.Cur,CustomCursor.Cursor1. 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(),"Cursor1.Cur" );
}

};
}

[STAThread]
int main()
{
Application::Run( gcnew CustomCursor::Form1 );
}

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.GetExecutingAssembly().GetManifest ResourceStream("MyProjectNamespace.Images.MyCursor .cur"));

Where MyProjectNamespace 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
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...
2
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...
3
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: ...
2
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....
15
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...
1
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?...
0
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...
4
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.