By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,715 Members | 1,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,715 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.