110,571
社区成员
发帖
与我相关
我的任务
分享
protected override void WndProc(ref Message m)
{
if (m.HWnd == this.Handle && m.WParam == this.button1.Handle )
{
// MessageBox.Show("找到了控件");
}
base.WndProc(ref m);
}
class WinAPI
{
[DllImport("coredll.dll")]
private static extern IntPtr SetCapture(IntPtr hWnd);
[DllImport("coredll.dll")]
private static extern IntPtr GetCapture();
public static IntPtr GetHWnd(Control ctrl)
{
IntPtr hOldWnd = GetCapture();
ctrl.Capture = true;
IntPtr hWnd = GetCapture();
ctrl.Capture = false;
SetCapture(hOldWnd);
return hWnd;
}
}
m.HWnd = WinAPI.GetHWnd(Button1);