using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication11
{
public partial class Form1 : Form, IMessageFilter
{
public Form1()
{
InitializeComponent();
Application.AddMessageFilter(this);
}
bool IMessageFilter.PreFilterMessage(ref Message m)
{
if (m.Msg == 0x201)
{
Control C = GetControl(this);
if (C != null)
MessageBox.Show(C.Name);
return true;
}
return false;
}
Control GetControl(Control C)
{
Control Temp = C.GetChildAtPoint(C.PointToClient(Cursor.Position));
if (Temp == null)
return C;
else
return GetControl(Temp);
}
}
}