• 使用预设半透明鼠标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;
    }
    }
    }

  • 相关阅读:
    mysql索引
    mysql锁机制
    mysql授权
    mysql执行计划
    mysql知识补遗
    求助:springboot调用存储过程并使用了pagehelper分页时报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
    java面试题1
    Yarn
    MapRudecer
    Hive数据倾斜和解决办法
  • 原文地址:https://www.cnblogs.com/z5337/p/3325246.html
Copyright © 2020-2023  润新知