Implement color cursors, animation cursors, and custom cursors in .NET

xiaoxiao2021-03-06  119

The following is a complete example, you can be able to see the effect by the command line. Test.cs Using System; Using System.drawing; Using System.windows.Forms; Using System.Runtime.InteropServices; Using System.Reflection; Namespace Colorcursor {///

// / This example effect: /// Implement color cursors, animation cursors, and custom cursors in .NET. /// public class Form1: System.Windows.Forms.Form {[DllImport ( "user32.dll")] public static extern IntPtr LoadCursorFromFile (string fileName); [DllImport ( "user32.dll")] public static extern IntPtr SetCursor (IntPtr cursorHandle); [DllImport ( "user32.dll")] public static extern uint DestroyCursor (IntPtr cursorHandle); [STAThread] static void Main () {Application.Run (new Form1 ());} public Form1 () {this.text = "Welcome"; cursor mycursor = new cursor (cursor.current.handle); //dinosau2.ani is the cursor comes with Windows: INTPTR ColorcursorHandle = loadingCursorFromFile (@ "C: / WinNT / Cursors / dinosau2.ani ");. myCursor.GetType () InvokeMember (" handle ", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetField, null, myCursor, new object [] {colorCursorHandle}); this .Cursor = mycursor;}}}

转载请注明原文地址:https://www.9cbs.com/read-99997.html

New Post(0)