成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

.NET實現彩色光標和自定義光標

2010-08-28 10:44:50來源:西部e網作者:

  本例子在.NET中實現彩色光標,動畫光標和自定義光標,下面是完整的例子,可以通過命令行編譯即可看到效果。


  Test.cs

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

  namespace ColorCursor
  {
  /// <summary>
  /// 本例子的作用:
  /// 在.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 = "歡迎光臨【孟憲會之精彩世界】:http://dotnet.aspx.cc/";
  Cursor myCursor = new Cursor(Cursor.Current.Handle);
  //dinosau2.ani為windows自帶的光標:
  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;
  }
  }
  }


 

關鍵詞:光標
主站蜘蛛池模板: 板桥市| 玉溪市| 广河县| 巍山| 兴城市| 大宁县| 墨脱县| 滁州市| 永嘉县| 宁城县| 平塘县| 西林县| 肇东市| 潢川县| 牙克石市| 阿合奇县| 夏邑县| 合江县| 阿城市| 云浮市| 林周县| 呼伦贝尔市| 巴南区| 筠连县| 漠河县| 高唐县| 娄底市| 新昌县| 西乌珠穆沁旗| 随州市| 厦门市| 新河县| 阜平县| 晋州市| 神农架林区| 清水河县| 汕尾市| 都兰县| 龙胜| 昔阳县| 乳源|