открытый класс GlobalMouseHandler: IMessageFilter
{
public delegate void EventHandlerForActiveState();
public event EventHandlerForActiveState onActive;
public event EventHandlerForActiveState onStateChanged;
private const int WM_KEYDOWN = 0x100;
//private const int WM_HSCROLL = 0x114;
//private const int WM_VSCROLL = 0x115;
private const int WM_LBUTTONDOWN = 0x201;
private const int WM_LBUTTONUP = 0x202;
private const int WM_RBUTTONDOWN = 0x204;
private const int WM_RBUTTONUP = 0x205;
//private const int WM_MBUTTONDBLCLK = 0x209;
private const int WM_MOUSEWHEEL = 0x20A;
private const int WM_GETMINMAXINFO = 0x024;
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 275)
{
return false;
}
switch (m.Msg)
{
case WM_LBUTTONDOWN:
if (onActive != null)
onActive();
break;
case WM_LBUTTONUP:
if (onActive != null)
onActive();
break;
case WM_RBUTTONDOWN:
if (onActive != null)
onActive();
break;
case WM_RBUTTONUP:
if (onActive != null)
onActive();
break;
case WM_MOUSEWHEEL:
if (onActive != null)
onActive();
break;
//case WM_ACTIVATE:
// if (onActive != null)
// onActive();
// break;
case WM_KEYDOWN:
if (onActive != null)
onActive();
break;
case WM_GETMINMAXINFO:
if (onStateChanged != null)
onStateChanged();
break;
//case WM_HSCROLL:
// if (onActive != null)
// onActive();
// break;
//case WM_VSCROLL:
// if (onActive != null)
// onActive();
// break;
}
return false;
}
}
дескриптор GlobalMouseHandler = новый GlobalMouseHandler ();
handle.onActive + = new GlobalMouseHandler.EventHandlerForActiveState (handle_onActive);
Application.AddMessageFilter (ручка);
Я использовал этот класс и сделал это.