其实这不是一个高深的问题,只为记录,带忘记时以便快速找回。
以下是整个事件的回溯(请注意是倒推):
1.委托的挂接与执行,参见http://www.cnblogs.com/flashvan/archive/2005/09/06/230752.html
2.Button.OnClick可追溯到Control.WmMouseUp
}
else {
//OnDoubleClick(EventArgs.Empty);
OnDoubleClick(new MouseEventArgs(button, 2, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
OnMouseDoubleClick(new MouseEventArgs(button, 2, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
}
}
//call the MouseUp Finally...
OnMouseUp(new MouseEventArgs(button, clicks, NativeMethods.Util.SignedLOWORD(m.LParam), NativeMethods.Util.SignedHIWORD(m.LParam), 0));
题外:通过源代码,另外可知Click先于MouseUp事件.
3.Control.WmMouseUp则在Control.WndProc执行
case NativeMethods.WM_MBUTTONUP:
WmMouseUp(ref m, MouseButtons.Middle, 1);
break;
case NativeMethods.WM_XBUTTONUP:
WmMouseUp(ref m, GetXButton(NativeMethods.Util.HIWORD(m.WParam)), 1);
break;
4.WndProc又在哪调用,参见http://blog.csdn.net/caimouse/archive/2010/01/02/5120173.aspx
关于“可以将WndProc看作由DispatchMessage进行调用”,一直在争,个人觉得这种说法,没有任何问题。
5.DispatchMessage
Ln001:{
Ln002: TranslateMessage(&msg);
Ln003: DispatchMessage(&msg);
Ln004:}
6.而GetMessage,可参见:http://blog.csdn.net/fireseed/archive/2002/09/10/2176.aspx
原文是MSDN,Bob Gunderson,深入GetMessage和PeekMessage。这篇文章,相当透彻,需仔细阅读。
最后,本文只是一篇文章索引,正如文章的初衷,以此方便日后追溯。