static Cursor

M

Martijn Mulder

I load my custom cursor with the constructor call

System.Windows.Forms.Cursor mycursor=new
System.Windows.Forms(GetType(),"MyCursor.Cur");

and the appropriate command line

csc -target:winexe -res:MyCursor.Cur,MyNamespace.MyCursor.Cur *.cs

This works well. But if I want to have a static cursor, I cannot use
GetType(). Fortunately there is another constructor that does without
GetType():

System.Windows.Forms.Cursor mycursor=new
System.Windows.Forms("MyCursor.Cur");

and the same command line. This also works well. But the problem is, in the
latter case, when I move the application out of original directory, the app
crashes. In the former case the resource is correctly linked in and I can
run the program from any directory.

How can I embed a static cursor in my application and run it from anywhere?

(The program size reveals that in the latter case the cursor IS embedded in
the app, but is not used, apperently)
 
J

Jon Skeet [C# MVP]

Martijn Mulder said:
I load my custom cursor with the constructor call

System.Windows.Forms.Cursor mycursor=new
System.Windows.Forms(GetType(),"MyCursor.Cur");

and the appropriate command line

csc -target:winexe -res:MyCursor.Cur,MyNamespace.MyCursor.Cur *.cs

This works well. But if I want to have a static cursor, I cannot use
GetType(). Fortunately there is another constructor that does without
GetType():

System.Windows.Forms.Cursor mycursor=new
System.Windows.Forms("MyCursor.Cur");

and the same command line. This also works well. But the problem is, in the
latter case, when I move the application out of original directory, the app
crashes. In the former case the resource is correctly linked in and I can
run the program from any directory.

How can I embed a static cursor in my application and run it from anywhere?

(The program size reveals that in the latter case the cursor IS embedded in
the app, but is not used, apperently)

Use typeof(...) to get a Type reference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top