Click here to Skip to main content
15,915,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<b>hi pals,
i have created my own cursor file(.cur /.ani. how can i add that into my winform.
i have tried these followig methods. but it doesnt work out</b>
The following generates a cursor from an embedded resource.
To add a custom cursor, create or use an existing 16x16 bitmap
1. Add a new cursor file to your project:
File->Add New Item->Local Project Items->Cursor File
2. Select 16x16 image type:
Image->Current Icon Image Types->16x16
--- To make the custom cursor an embedded resource ---
In Visual Studio:
1. Select the cursor file in the Solution Explorer
2. Choose View->Properties.
3. In the properties window switch "Build Action" to "Embedded"
On the command line:
Add the following flag:
/res:CursorFileName.Cur,Namespace.CursorFileName.Cur

Where "Namespace" is the namespace in which you want to use
the cursor and "CursorFileName.Cur" is the cursor filename.
The following line uses the namespace from the passed-in type
and looks for CustomCursor.MyCursor.Cur in the assemblies manifest.
NOTE: The cursor name is case sensitive.
this.Cursor = new Cursor(GetType(), "MyCursor.Cur");


can anyone please help me to overcome this issue.
Posted

1 solution

The class System.Windows.Forms.Cursor does support custom cursors, but not colored and not animated. This is explicitly specified in MSDN documentation:

http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor%28v=vs.100%29.aspx[^].

This is a workaround based on raw Windows API, P/Invoked:

http://stackoverflow.com/questions/4305800/using-custom-colored-cursors-in-a-c-sharp-windows-application[^].

—SA
 
Share this answer
 
Comments
valiant123 2-Mar-12 5:00am    
works fine thanks :)
Sergey Alexandrovich Kryukov 2-Mar-12 8:53am    
You are welcome.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900