Face is a complete example, you can see the effect by compiling the command line.
Test.cs
Using System;
Using System.Drawing;
Using System.Windows.Forms;
Using System.Runtime.InteropServices;
Using System.Reflection;
Namespace Colorcursor
{
<summary>
The role of this example:
Implement color cursors, animated cursors, and custom cursors in. Net.
</summary>
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 Wonderful World of Mengxian ": http://dotnet.aspx.cc/";
Cursor mycursor = new Cursor (Cursor.Current.Handle);
Dinosau2.ani for Windows with its own 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;
}
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.