Implement color cursors and custom cursors in .NET

xiaoxiao2021-03-06  74

This example implements a color cursor, an animation cursor, and a custom cursor in .NET, the following is a complete example, you can be compiled 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" 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-93095.html

New Post(0)