ur message handler code here and/or call defaultР?if(point.x<m_rect.right&&point.x>m_rect.left)Р?{Р MessageBox("击中矩形");Р?}Р?elseР?{Р m_rect.SetRect(point.x-50,point.y-50,point.x+50,point.y+50);Р Invalidate();Р?}Р?CView::OnLButtonDown(nFlags, point);Р}Рvoid CMy4_33View::OnRButtonDown(UINT nFlags, CPoint point) Р{Р?// TODO: Add your message handler code here and/or call defaultР?if(point.x<m_rect.right&&point.x>m_rect.left)Р?{Р MessageBox("击中矩形");Р?}Р?elseР?{Р m_rect.SetRect(point.x-50,point.y-50,point.x+50,point.y+50);Р Invalidate();Р?}Р?CView::OnRButtonDown(nFlags, point);Р}Р在成员函数CMyMessageView::OnDraw()中添加如下粗体代码:Рvoid CMy4_33View::OnDraw(CDC* pDC)Р{Р?CMy4_33Doc* pDoc = GetDocument();Р?ASSERT_VALID(pDoc);Р?// TODO: add draw code for native data hereР?pDC->Rectangle(&m_rect);Р}Р编译并运行程序得到结果: