VC6新建一个多文档项目;根据窗口标题的最后数字,绘制不同图形;
void CPrdView::OnDraw(CDC* pDC)
{
CPrdDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString str1 = pDoc->GetTitle();
CPoint pt[4];
//起点
pt[0].x = 20;
pt[0].y = 20;
//第一条线终点
pt[1].x = 20;
pt[1].y = 160;
//第二条线终点
pt[2].x = 150;
pt[2].y = 140;
//回到起点
pt[3].x = 20;
pt[3].y = 20;
CRgn rgn;
CBrush brush;
int ti = atoi(str1.Right(1));
switch(ti)
{
case 1:
pDC->Rectangle(5,5,150,150);
break;
case 2:
pDC->Ellipse(5,5,150,150);
break;
case 3:
pDC->Ellipse(5,5,250,150);
break;
case 4:
pDC->Arc(5,5,250,100,5,100,250,100);
break;
case 5:
pDC->Polygon(pt,3);
break;
case 6:
rgn.CreatePolygonRgn( pt, 3, ALTERNATE); //创建区域
brush.CreateSolidBrush( RGB( 0, 255, 0 ) ); //创建画刷
pDC->FillRgn( &rgn, &brush );
break;
default:
break;
}
}