100分请教高手问题:无法重载系统底层WndProc(ref Message m)函数
前天自己写了一个自定义的控件,继承ListView,并且调用地层的WndProc(ref Message m)
来捕获系统的消息,然而无论如何我在测试时候程序始终无法运行到WndProc(ref Message m)内部的函数(设置断点):
[SecurityPermission(SecurityAction.LinkDemand, flags=SecurityPermissionFlag.UnmanagedCode)]
protected override void WndProc(ref Message m)
{
if (m.Msg ==(int) Win32.Consts.WM_NCPAINT)
_backgroundDirty = true;
if (m.Msg == (int)Win32.Consts.WM_ERASEBKGND)
{
if (ProcessBackground() == false)
{
return;
}
}
if (m.Msg == (int)Win32.Consts.OCM_NOTIFY)
{
Win32.NMHDR notifyHeader = (Win32.NMHDR)m.GetLParam(typeof(Win32.NMHDR));
if (notifyHeader.code == (int)Win32.Consts.LVN_ITEMCHANGED)
_paintBackground = false;
if (notifyHeader.hwndFrom.Equals(this.Handle) && notifyHeader.code == (int)Win32.Consts.NM_CUSTOMDRAW)
{
_paintBackground = true;
if (ProcessListCustomDraw(ref m))
return;
}
}
base.WndProc(ref m);
}
WndProc理解成一个死循环,不断的从消息队列里面获取消息,这里设下断点无论如何都会运行到的,然而现在却无法捕获任何消息(没有运行这段函数),究竟是怎么回事?