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

xiaoxiao2021-03-06  117

The surface is a complete example, you can be able to see the effect by the command line.

Test.cs

Using system.drawing; using system.windows.forms; using system.runtime.interopservices; using system.reflection;

Namespace Colorcursor {///

/// This example The effect: /// Implement color cursor, animation cursor, and custom cursor 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" Wonderful World]: http://dotnet.aspx.cc/ "; cursor mycursor = new cursor (current.handle); //dinosau2.ani For windows that comes with the cursor: IntPtr colorCursorHandle = LoadCursorFromFile (@ "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-102828.html

New Post(0)