這篇文章主要介紹了winform實現限制及解除鼠標移動范圍的方法,涉及C#控制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#程序設計有所幫助。
新聞熱點
疑難解答