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;
    }
    }
    }

  • 相关阅读:
    从服务器角度分析RPG游戏——NPC的AI
    羽翼特效设计
    坐骑特效设计(二)
    坐骑特效设计
    Unity AssetBundle打包资源工具
    有趣的进度条
    原生与组件
    bower
    yeoman
    grunt+bower+yo
  • 原文地址:https://www.cnblogs.com/z5337/p/3325246.html
Copyright © 2011-2022 走看看