How to change the standard cursor on your own? For example, I put a file into resources:
MySOrce.cur is the cursor itself.
I used many methods, but I can’t use it from resources at all!
In the resource itself, the file is named without .cur That is, just the name MySOrce
Used this method:
Class:
class NewCursorAPI { public static Cursor LoadCustomCursor(string path) { IntPtr hCurs = LoadCursorFromFile(path); if (hCurs == IntPtr.Zero) throw new Win32Exception(); var curs = new Cursor(hCurs); // Note: force the cursor to own the handle so it gets released properly var fi = typeof(Cursor).GetField("ownHandle", BindingFlags.NonPublic | BindingFlags.Instance); fi.SetValue(curs, true); return curs; } [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern IntPtr LoadCursorFromFile(string path); } Then use:
public FormLoader() { InitializeComponent(); this.Cursor = NewCursorAPI.LoadCustomCursor(@"c:\windows\cursors\aero_busy.ani"); } But the cursor appears only if the file itself is located somewhere in the folder on the computer itself, and you need to make it run from resources!