MFC,以下内容运行后显示正常
void CTest01View::OnDraw(CDC* pDC)
{
CTest01Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
//定义画笔绘制矩形
CPen pen(PS_DASH, 2, RGB(0,0,255)); //虚线 粗2 蓝色
pDC->SelectObject(&pen);
//定义坐标点
CPoint point1(100,150);
CPoint point2(400,300);
//绘制矩形
pDC->Rectangle(point1.x, point1.y, point2.x, point2.y);
}
改为这样在OnDraw中调用运行后不显示图案,希望指出原因
void CMFCApplication1View::rec(CDC* pDC,CPoint point1,CPoint point2)
{
//定义画笔绘制矩形
CPen pen(PS_DASH, 2, RGB(0, 0, 255)); //虚线 粗2 蓝色
pDC->SelectObject(&pen);
//绘制矩形
pDC->Rectangle(point1.x, point1.y, point2.x, point2.y);
}