zoukankan      html  css  js  c++  java
  • 使用预设半透明鼠标Cursor

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Reflection;

    namespace WindowsApplication1
    {
    public class Form1 : Form
    {
    [DllImport("user32.dll")]
    static extern IntPtr LoadCursorFromFile(string fileName);

    public Form1()
    {
    InitializeComponent();
    }

    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
    if (disposing && (components != null))
    {
    components.Dispose();
    }
    base.Dispose(disposing);
    }

    #region Windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.SuspendLayout();
    //
    // Form1
    //
    this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
    this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    this.ClientSize = new System.Drawing.Size(292, 273);
    this.Name = "Form1";
    this.Text = "Form1";
    this.Click += new System.EventHandler(this.Form1_Click);
    this.ResumeLayout(false);

    }

    #endregion

    int i = 0;
    private void Form1_Click(object sender, EventArgs e)
    {
    i++;
    if (i % 2 == 1)
    Cursor.Hide();
    else
    {
    Cursor.Show();
    i = 0;
    }
    //Cursor = new Cursor("Arrow.ani");
    Cursor customCursor = new Cursor(Cursor.Current.Handle);
    IntPtr customCursorHandle = LoadCursorFromFile("Arrow.ani");
    customCursor.GetType().InvokeMember("handle", BindingFlags.Public |
    BindingFlags.NonPublic | BindingFlags.Instance |
    BindingFlags.SetField, null, customCursor,
    new object[] { customCursorHandle });
    this.Cursor = customCursor;
    }
    }
    }

  • 相关阅读:
    PHPUnit断言详情
    dev tools杂谈
    sublime text3 + python3.5 ide
    文件传输接收sz、rz命令用法
    Linux编辑器vi使用方法详细介绍
    vi编辑字符串替换及sed用法
    Selenium实战(一)——浏览器实例
    Python的数据库连接
    Cypress测试框架——一个简单的测试用例
    Cypress测试框架——入门1
  • 原文地址:https://www.cnblogs.com/z5337/p/3325246.html
Copyright © 2011-2022 走看看