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" <poliphant@RoundTripInc.com> wrote in message
news:ut$TXOpAGHA.216@TK2MSFTNGP15.phx.gbl...[color=blue]
> 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]" <willy.denoyette@telenet.be> wrote in message
> news:%23DchcDpAGHA.360@TK2MSFTNGP09.phx.gbl...[color=green]
>>
>> "Peter Oliphant" <poliphant@RoundTripInc.com> wrote in message
>> news:%235CedynAGHA.3584@TK2MSFTNGP14.phx.gbl...
>>[color=darkred]
>>>
>>>
http://msdn2.microsoft.com/en-us/lib...ms.cursor.aspx
>>>
>>> So I guess MS itself is keeping this a secret. Oh goody! : )
>>>
>>> [==P==]
>>>
>>>[/color]
>>
>> 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.
>>
>>[/color]
>
>[/color]