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

xiaoxiao2021-03-06  115

Author: Meng will Microsoft MVPTest.cs

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

namespace ColorCursor {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 to the 21st Century ASP.NET Technology Network: http://www.21asp.net/"; CURSOR MyCURSOR = New Cursor (Cursor.current.Handle); //dinosau2.ani comes with Windows 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-101716.html

New Post(0)