How to Embed a Cursor

B

bern11

How do you embed a cursor in a project and use it? I created a cursor
in a project, I can use it using the Cursor(String) constructor, but I
cannot get it to work with the Cursor(Type,String) constructor. I'm
missing something really simple.

The resource view has an ID assigned to it, do I use that?

How do I re-assign the hot-spot? (It is greyed-out in the properties
view and stuck at (0,0)).
 
D

Dave Sexton

Hi,
How do you embed a cursor in a project and use it? I created a cursor in a project, I can use it using the Cursor(String)
constructor, but I cannot get it to work with the Cursor(Type,String) constructor. I'm missing something really simple.

The resource view has an ID assigned to it, do I use that?

The Type parameter is used to scope the embedded resource name.

If you are using Visual Studio.NET 2005 you can add a new Resource file to your project. Once added, open the file and select
"Other" from the drop-down that appears under the list of tabs. Then select "Add Existing File..." from the drop-down to its right.
Browse to your cursor file and add it to the resource file. Now call a different constructor of the Cursor class that takes only a
Stream parameter just like this (assuming your resource file is named, "MyResourceFile" and your cursor is named, "MyCustomCursor"):

Cursor cursor;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(MyResourceFile.MyCustomCursor))
{
cursor = new Cursor(stream);
}

If you are using an older version of Visual Studio.NET you can view the Properties Window, after selecting the cursor file in
Solution Explorer, and set "Build Action" to "Embedded Resource". When you call the Cursor constructor pass in a Type that exists
in the same namespace as the cursor file. In C# projects each namespace is a folder in the heirarchy of folders that contains the
cursor file, excluding the project folder itself (I'm not sure how this works in VB). The name of the resource is the name of the
file and its extension.

Note that the Cursor class only supports black & white cursors:

(watch for wrapping)
http://groups.google.com/group/micr...r+black+&+white+color&rnum=2#74d09c617772f136
How do I re-assign the hot-spot? (It is greyed-out in the properties view and stuck at (0,0)).

In the "Image Editor" toolbar of VS.NET there is an icon that looks like a black arrow pointing at a spark. That is the "Set Hot
Spot Tool".
 

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

Similar Threads

How to change cursor. 10
Embed a cursor 2
Cursor location 3
wpf animated cursor 0
static Cursor 1
How can I find my lost cursor? 2
Embed a Custom Cursor? 4
embedding a cursor in an application 2

Top