C#
C# 커서 바꾸기
outshine90
2014. 11. 12. 11:43
커서 바꾸기
static class NativeMethods { [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] private static extern IntPtr LoadCursorFromFile(string path); public static Cursor LoadCustomCursor(string path) { IntPtr hCurs = LoadCursorFromFile(path); if (hCurs == IntPtr.Zero) throw new Win32Exception(); Cursor curs = new Cursor(hCurs); FieldInfo fi = typeof(Cursor).GetField("ownHandle", BindingFlags.NonPublic | BindingFlags.Instance); fi.SetValue(curs, true); return curs; } }
Cursors.Current = NativeMethods.LoadCustomCursor("MyCursor.cur");