OnWndMsg是在 Cwnd 中定义的虚函数;CWnd::OnWndMsg
virtual BOOL OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult );
Remarks
This member function is called by WindowProc, or is called during message reflection.
因为不管是什么类型的窗口基类的根源几乎都是CWnd(在MFC中);
所以巧妙的利用这个函数可以实现很多不能正常办法实现的问题;
简单举例子就是:
在 ListCttl中 Head的鼠标右击消息;
利用OnWndMsg截取Head的WM_RBUTTONUP消息
然后自定义消息发送给所需要的窗口中去;
利用OnWndMsg无所不能
BOOL CMainFrame::OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
if(m_bActive)
{
static unsigned long i=0;
i++;
char buf[256];
sprintf(buf,"%08ld:%08X %08X %08X %08X",
i,message, wParam, lParam, pResult);
m_lb.InsertString(0,buf);
}
return CFrameWnd::OnWndMsg(message, wParam, lParam, pResult);
}