开发者

C# Winforms - change cursor icon of mouse

How to change cursor icon to the 'busy icon'开发者_JS百科 usually shown on the desktop? How can i set Animated files (.gif,.ani) instead of cursor ?


Try to do the following:

System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

More information is available at Cursors Class documentation

Cursor class doesn't support GIF files or animated cursors (.ANI). You can load a custom cursor doing

Cursor.Current = new Cursor("C:\\ic.cur");

Maybe you can convert yout GIF file to cursor format using a tool like Microangelo. In addition, there is another thread related to it.

How do you convert a GIF into a CUR file?


I have the answer for a picturebox

Picturebox1.cursor = new cursor(Properties.Resources.CURSOR NAME.GetHicon());


There is also simple pure-C# way:

System.Windows.Forms.Cursor cursor = null;      
var info = System.Windows.Application.GetResourceStream(
        new Uri(@"pack://application:,,,/Resources/MyCursor.cur"));
cursor = new System.Windows.Forms.Cursor(info.Stream);

The MyCursor.cur must be included as Resource in your project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜