c#程序控制鼠标

来源:百度知道 编辑:UC知道 时间:2024/06/06 19:18:14
如何运行一个C#程序时让鼠标的移动范围只在程序界面范围内呢?

你看下这篇:http://topic.csdn.net/t/20021225/11/1297793.html

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 WindowsApplication17
{
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)]
publ