C#中怎么样将鼠标锁定在某个特定的form上?
只能在上面移动,而不能移到外面去? --------------------编程问答-------------------- 把你的form大小设定的跟桌面一样大鼠标就出不去了现在的多任务操作系统想这么做不太好办 --------------------编程问答-------------------- Cursor.Clip试试
--------------------编程问答--------------------
using System;--------------------编程问答-------------------- 学习楼上。 --------------------编程问答-------------------- 三楼的代码能否保证在按Ctrl+Alt+Del的时候也有效?
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);
}
}
}
或者按Alt+Tab的时候 --------------------编程问答-------------------- 呵,要保证按快捷键也有效那好象要用键盘钩子了吧
补充:.NET技术 , C#