void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("Fram clicked");
CFrameWnd::OnLButtonDown(nFlags, point);
}书上说在客户区view把frame覆盖了
可是在菜单栏上点鼠标还是不响应
但是在View窗口中映射了OnLButtondown用下面代码却能在菜单栏上划线
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
}
why???
{
// TODO: Add your message handler code here and/or call default
MessageBox("Fram clicked");
CFrameWnd::OnLButtonDown(nFlags, point);
}书上说在客户区view把frame覆盖了
可是在菜单栏上点鼠标还是不响应
但是在View窗口中映射了OnLButtondown用下面代码却能在菜单栏上划线
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
}
why???
可是在菜单栏上点鼠标还是不响应
==========================
你说的菜单栏是指点菜单还是点空白区啊,点空白区的话,不管是CMainFrame还是CView类都不会响应,因为那不是客户区。
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
}
why??? 这是因为GetParent()并不见的就是CFrameWnd
void CMainFrame::OnLButtonDown
我是在框区响应的消息应该在菜单栏响应
当然使用PreTranslateMessage的话可以在消息被路由之前就能截获并处理,在WindowProc中也一样能提前截获。
Frame是程序的框,不要让它做这些事情 。~~~~~~~~
void CDrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
CClientDC dc(GetParent());
dc.MoveTo(m_ptOrigin);
dc.LineTo(point);
} 对于菜单或者工具栏的命令消息,首先交给活动文档,如果活动文档不处理就交给活动视图,如果活动视图不处理就交给主窗口,如果主窗口不处理就交给CWinApp,它再不处理就做默认处理(什么都不做)。
当然使用PreTranslateMessage的话可以在消息被路由之前就能截获并处理,在WindowProc中也一样能提前截获。
!!!!!!!!!!!
ON_WM_LBUTTON 是命令消息???这不是明显的标准消息吗?
拦截这个WM_NCLBUTTONDOWN问题解决