using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsApplication12 { public partial class Form1 : Form { [DllImport("User32.dll")] public static extern int ClipCursor(ref Rect r); public Form1() { InitializeComponent(); } [StructLayout(LayoutKind.Explicit)] public struct Rect { [FieldOffset(0)] public int left; [FieldOffset(4)] public int top; [FieldOffset(8)] public int right; [FieldOffset(12)] public int bottom; } private void Form1_Load(object sender, EventArgs e) { } private void Form1_MouseMove(object sender, MouseEventArgs e) { Rect a; Rectangle r = this.ClientRectangle; r.Offset(this.Location); a.top = r.Top; a.right = r.Right; a.bottom = r.Bottom; a.left = r.Left; ClipCursor(ref a); } } }
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsApplication12
{
public partial class Form1 : Form
{
[DllImport("User32.dll")]
public static extern int ClipCursor(ref Rect r);
public Form1()
{
InitializeComponent();
}
[StructLayout(LayoutKind.Explicit)]
public struct Rect
{
[FieldOffset(0)]
public int left;
[FieldOffset(4)]
public int top;
[FieldOffset(8)]
public int right;
[FieldOffset(12)]
public int bottom;
} private void Form1_Load(object sender, EventArgs e)
{ } private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Rect a;
Rectangle r = this.ClientRectangle;
r.Offset(this.Location);
a.top = r.Top;
a.right = r.Right;
a.bottom = r.Bottom;
a.left = r.Left;
ClipCursor(ref a);
}
}
}