Tell me how to change the cursor to your own? I do this:

Cursor cur = new Cursor(new System.IO.MemoryStream(global::MSU.Properties.Resources.cursorDragDrop)); 

Writes an error -

The most appropriate overloaded method for "System.IO.MemoryStream.MemoryStream (int)" has several invalid arguments

    1 answer 1

    For example, you can do this (from the available cursors):

     Cursor.Current = Cursors.WaitCursor; 

    Or your cursor like this:

     Cursor.Current = new Cursor("C:\\<путь к файлу>\\icon.cur"); 

    By the way, pay attention to the file extension .cur , for example .gif you can not pack there. VisualStudio has the ability to create a Cursor File (at least it was). All you need is to specify the path to the file and, strictly speaking, the file itself. Will be useful: Cursors - properties


    If you want to stitch it into a program, then I think you should add the cursor file ( .cur ) to the project resources. Then in the code to get this file, convert and create a cursor, something like this:

     var img = new Bitmap(WindowsFormsApplication1.Properties.Resources.myCursor); Icon icon = Icon.FromHandle(img.GetHicon()); Cursor cur = new Cursor(icon.Handle); Cursor.Current = cur; 

    This code is given as an alternative example, but it has its drawbacks in the form of leaking native resources. Also, if you click the mouse in the window of another program - a problem may arise. Therefore, I advise you to read this answer Cursor HotSpot in WinForms .NET , it will be more correct using WinAPI .

    • And you can not somehow sew into the program? - Winteriscoming
    • @Winteriscoming, I think that you can easily add a file to the project and from there take it, no one forbids it. - Denis Bubnov
    • @Winteriscoming, see answer addition - Denis Bubnov
    • The second option works! - Winteriscoming
    • one
      @Qwertiy, added the answer. Thanks for the tip. - Denis Bubnov