亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C# Form自定義光標(biāo)的簡單實(shí)現(xiàn)

 更新時(shí)間:2014年01月14日 16:15:36   作者:  
這篇文章主要介紹了C# Form自定義光標(biāo)的簡單實(shí)現(xiàn),有需要的朋友可以參考一下

下面是完整的例子,可以通過命令行編譯即可看到效果。

復(fù)制代碼 代碼如下:

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;

namespace ColorCursor
{
 /// <summary>
 /// 本例子的作用: 在.NET中實(shí)現(xiàn)自定義光標(biāo)。
 /// </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()
        {
            Cursor myCursor = new Cursor(Cursor.Current.Handle);
            IntPtr colorCursorHandle = LoadCursorFromFile(@"C:WINNTCursorsdinosau2.ani" );   
            //dinosau2.ani為windows自帶的光標(biāo):

            myCursor.GetType().InvokeMember("handle",BindingFlags.Public |
            BindingFlags.NonPublic | BindingFlags.Instance |
            BindingFlags.SetField,null,myCursor,
            new object [] { colorCursorHandle } );
            this.Cursor = myCursor;
        }
    }
}

相關(guān)文章

最新評(píng)論