实现效果:
知识运用:
Cursor类中的相关属性
实现代码:
private void button1_Click(object sender, EventArgs e) { this.Cursor = new Cursor(Cursor.Current.Handle); //创建Cursor对象 Cursor.Position = new Point(Cursor.Position.X,Cursor.Position.Y); //设置鼠标位置 Cursor.Clip = new Rectangle(this.Location,this.Size); //设置活动区域 } private void button2_Click(object sender, EventArgs e) { this.Cursor = new Cursor(Cursor.Current.Handle); Screen[] screen = Screen.AllScreens; //获取显示的数组 Cursor.Clip= screen[0].Bounds; //解除活动区域的限制 }