zoukankan      html  css  js  c++  java
  • c#自定义鼠标形状

    更改鼠标指针,需要使用到 Windows API:

    1. 添加命名空间的引用:

    using System.Runtime.InteropServices; 
    using System.Reflection;

    2. 声明 API 函数

    [DllImport("user32.dll")] 
    static extern IntPtr LoadCursorFromFile( string fileName );

    3. 在Form_Load 事件中,加载自定义光标

    private void Form1_Load(object sender, EventArgs e)
      {
          Cursor customCursor = new Cursor(Cursor.Current.Handle);
          IntPtr customCursorHandle = LoadCursorFromFile("你的自定义鼠标指针的路径");
          customCursor.GetType().InvokeMember("handle", BindingFlags.Public |
          BindingFlags.NonPublic | BindingFlags.Instance |
          BindingFlags.SetField, null, customCursor,
         new object[] { customCursorHandle });
         this.Cursor = customCursor;
      }
  • 相关阅读:
    iOS开发-Sqlite
    iOS开发-HTTP协议
    iOS开发
    iOS 开发小记 (八)
    iOS
    iOS开发-基础框架
    Java门面模式
    Linux常用命令
    canal使用小结
    MySQL隔离级别的测试
  • 原文地址:https://www.cnblogs.com/edangame/p/6943900.html
Copyright © 2011-2022 走看看