using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
[DllImport("user32.dll", EntryPoint = "ShowCursor", CharSet = CharSet.Auto)]
public static extern int ShowCursor(int status);
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 隐藏鼠标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
while (ShowCursor(0) >= 0)
{
ShowCursor(0);
}
}
/// <summary>
/// 显示鼠标
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
while (ShowCursor(1) < 0)
{
ShowCursor(1);
}
}
}
}