Winform清理粘贴板

各位大虾好
小弟想写一个锁屏的程序
让鼠标和键盘事件只能在winform窗体中触发  
并且鼠标移不出winform窗体
谢谢各位
------回答---------

------其他回答(20分)---------

http://www.codeproject.com/KB/cs/globalhook. asp x
用这个库,一般的钩子一个函数一行代码足以。
------其他回答(30分)---------

这个方法在鼠标狂甩的情况下无效。。。。
C# code
   
   
private void Form1_MouseMove(object sender, MouseEventArgs e) { Point p = this.Location; label1.Text = "form>>" + p.X.ToString() + " : " + p.Y.ToString(); Point t = new Point(e.X,e.Y); t = PointToScreen(t); label2.Text = "mouse>>" + t.X.ToString() + " : " + t.Y.ToString(); if (t.X <= p.X + 10 ) { Cursor.Position = new Point(p.X + 10, t.Y); } else if (t.Y <= p.Y + 30) { Cursor.Position = new Point(t.X, p.Y + 30); } else if (t.X >= p.X + this.Width - 10) { Cursor.Position = new Point(p.X + this.Width - 10, t.Y); } else if (t.Y >= p.Y + this.Height - 30) { Cursor.Position = new Point(t.X, p.Y + this.Height - 30); } }
------其他回答(5分)---------

Cursor.Clip = RectangleToScreen(DisplayRectangle);
------其他回答(5分)---------

没啥难度,挂钩desktop的窗口句柄,截获鼠标移动消息就行了,请问下楼主应用场景是什么?
------其他回答(10分)---------

C# code
   
   
Cursor.Clip = RectangleToScreen(DisplayRectangle);
------其他回答(30分)---------

方法1:
C# code
   
   
private const int wm_nchittest = 0x84; private const int htclient = 0x1; private const int htcaption = 0x2; protected override void WndProc(ref System.Windows.Forms.Message m) { switch (m.Msg) { case wm_nchittest: base.WndProc(ref m); if ((int)m.Result == htclient) m.Result = (IntPtr)htcaption; return; } base.WndProc(ref m); }

方法2:
C# code
   
   
private Point mouse_offset = new Point(0,0); private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { this.mouse_offset = new Point(-e.X,-e.Y); } private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button == MouseButtons.Left) { Point mousepos = Control.MousePosition; mousepos.Offset(this.mouse_offset.X,this.mouse_offset.Y-SystemInformation.CaptionHeight); this.Location = mousepos; } }

20140414

判断鼠标是否在窗体范围内

http://bbs.csdn.net/topics/340153012

http://www.cnblogs.com/wangjixianyun/archive/2013/02/25/2931582.html

mousemove的处理


http://www.isstudy.com/cjc/2087_2.html

具体的例子,但是我这就是不行,郁闷

我靠我靠我靠我靠我靠靠靠靠靠

this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.FormArchiveInput_MouseMove);

少写了第二句中的this,就因为这个错误,耽误了将近三个小时,时间就是这么浪费了,我靠靠靠靠

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值