winform实现限制及解除鼠标移动范围的方法


本文实例讲述了winform实现限制及解除鼠标移动范围的方法。分享给大家供大家参考。具体如下:

限制鼠标的移动范围:

// this.Cursor = new Cursor(this.Cursor.Handle);
// Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y);
Cursor.Clip = new Rectangle(this.Location, this.Size);

解除限制鼠标的移动范围:

Screen[] screen = Screen.AllScreens;
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Clip = screen[0].Bounds;

希望本文所述对大家的C#程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3