C 利用钩子控制鼠标【月儿原创】

C#利用钩子控制鼠标

作者:清清月儿

主页:http://blog.csdn.net/21aspnet/           时间:2007.5.11

工作中有这样的需求,某个控件panel的子控件textbox要实现只留鼠标右键copy,注意同时还不能影响其它panel的子控件textbox,怎么办?
答案是只有用钩子,在codeporject上找到这么一个钩子。

如图所示,第一个文本框只有copy功能。


UserActivityHook.cs

using  System;
using  System.Runtime.InteropServices;
using  System.Reflection;
using  System.Threading;
using  System.Windows.Forms;
using  System.ComponentModel;

namespace  gma.System.Windows
{
 
/// <summary>
 
/// This class allows you to tap keyboard and mouse and / or to detect their activity even when an 
 
/// application runes in background or does not have any user interface at all. This class raises 
 
/// common .NET events with KeyEventArgs and MouseEventArgs so you can easily retrieve any information you need.
 
/// </summary>

 public class UserActivityHook
 
{
  
Windows structure definitions

  
Windows function imports

猜你喜欢

转载自www.cnblogs.com/siwnchs/p/10178453.html