C#如何控制鼠标移动范围?
2个回答
展开全部
//锁定鼠标活动范围:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(this.Location,this.size);//这里是窗体的大小.即鼠标只能在窗体范围内活动.如果要改成控件,只改动this.Location,this.size.
}
如果是,textBox txtbox:则:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(txtbox.Location,txtbox.size);
}
希望对你有用!
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(this.Location,this.size);//这里是窗体的大小.即鼠标只能在窗体范围内活动.如果要改成控件,只改动this.Location,this.size.
}
如果是,textBox txtbox:则:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(txtbox.Location,txtbox.size);
}
希望对你有用!
推荐于2017-09-04
展开全部
锁定鼠标活动范围:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(this.Location,this.size);//这里是窗体的大小.即鼠标只能在窗体范围内活动.如果要改成控件,只改动this.Location,this.size.
}
如果是,textBox txtbox:则:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(txtbox.Location,txtbox.size);。
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(this.Location,this.size);//这里是窗体的大小.即鼠标只能在窗体范围内活动.如果要改成控件,只改动this.Location,this.size.
}
如果是,textBox txtbox:则:
void LockCursor()
{
this.Cursor=new Cursor(Cursor.Current.Handle);
Cursor.Position=new Point(Cursor.Position.X,Cursor.Position.Y);
Cursor.Clip=new Rectangle(txtbox.Location,txtbox.size);。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询