/[NexusPowerControl]/trunk/NexusPowerControl/MouseTrapper.cs
ViewVC logotype

Contents of /trunk/NexusPowerControl/MouseTrapper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (show annotations) (download)
Sun Oct 23 00:27:29 2011 UTC (8 years ago) by william
File size: 1011 byte(s)
*** implement trapping mouse to form

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows.Forms;
6 using System.Drawing;
7
8 namespace NexusPowerControl
9 {
10 public class MouseTrapper
11 {
12 // code paritally obtained from: http://stackoverflow.com/questions/5399000/lock-mouse-cursor-movement-only-in-a-control
13
14 public MouseTrapper()
15 {
16 }
17
18
19 public void TrapMouse(Form control)
20 {
21 Cursor.Position = new Point(control.Location.X+45, control.Location.Y+35);
22 Rectangle rc = new Rectangle(Cursor.Position, new Size(control.DisplayRectangle.Width - 105, control.DisplayRectangle.Height-85));
23 Cursor.Clip = rc;
24 control.Capture = true;
25 }
26 public void ReleaseMouse(Form control)
27 {
28 control.Capture = false;
29 control.Cursor = Cursors.Default;
30 Cursor.Clip = new Rectangle(0, 0, 0, 0);
31 }
32 }
33 }

  ViewVC Help
Powered by ViewVC 1.1.22