我的直觉里,一个鼠标的点击应该包含DOWN和UP,
如果我不重载OnLButtonDown, 那么UP消息能响应
如果我重载了OnLButtonDown,UP消息就得不到响应了,
怎么回事啊?
void CTestMDIView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("Up");
CView::OnLButtonUp(nFlags, point);
}void CTestMDIView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("Down");
CView::OnLButtonDown(nFlags, point);
}
如果我不重载OnLButtonDown, 那么UP消息能响应
如果我重载了OnLButtonDown,UP消息就得不到响应了,
怎么回事啊?
void CTestMDIView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("Up");
CView::OnLButtonUp(nFlags, point);
}void CTestMDIView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
AfxMessageBox("Down");
CView::OnLButtonDown(nFlags, point);
}
AfxMessageBox("Up");改为TRACE("Up");
就能看出来两个函数都调用了
void CxcdView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值 CDC *pDC=GetDC();
pDC->TextOut(0,0,_T("DOWN")); CView::OnLButtonDown(nFlags, point);
}void CxcdView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CDC *pDC=GetDC();
pDC->TextOut(0,20,_T("UP"));
CView::OnLButtonUp(nFlags, point);
}
AfxMessageBox("Down");
造成debug时,没有捕捉up信息。
换种方法试试。