[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// 0x210 is WM_PARENTNOTIFY
// 513 is WM_LBUTTONCLICK
if (m.Msg == 0x210 && m.WParam.ToInt32() == 513)
{
// get the clicked position
var x = (int)(m.LParam.ToInt32() & 0xFFFF);
var y = (int)(m.LParam.ToInt32() >> 16);
// get the clicked control
var childControl = this.GetChildAtPoint(new Point(x, y));
// call onClick (which fires Click event)
OnClick(EventArgs.Empty)
// do something else...
}
base.WndProc(ref m);
}
可能重複的[如何爲表單設置單擊事件?](http://stackoverflow.com/questions/180452/how-do-i-set-a-click-event-for -a-form) –
我在發佈之前已經檢查了該線程,但是我找不到實際的解決方案。以下處理窗口消息看起來很有希望。我測試後會回覆。 – TBKAY