分类: WINDOWS
2008-11-27 20:24:17
{
CPaintDC dc(this);
//////////////////////////////////////////////////////////////////////////
//*******画坐标图*******
//////////////////////////////////////////////////////////////////////////
int nxLength=400;
int nyLength=300;
int nxDivisionNumber = 7;
int nyDivisionNumber = 6;
int nMeshLength;
CString str;
int i;
CWnd *pWnd = GetDlgItem(IDC_DIAMETER_TIME_CURVE);
CDC* pDC = pWnd->GetDC();
pWnd->Invalidate();
pWnd->UpdateWindow();
pDC->Rectangle(0,0,nxLength,nyLength);
CPen* pPenRed = new CPen; //创建画笔对象
pPenRed->CreatePen(PS_SOLID, 1, RGB(255,0,0)); //红色画笔
CPen* pPenGreen = new CPen; //创建画笔对象
pPenGreen->CreatePen(PS_SOLID, 1, RGB(0,255,0));//绿色画笔
CPen* pPenBlue = new CPen; //创建画笔对象
pPenBlue->CreatePen(PS_DOT, 1, RGB(0,0,255)); //蓝色画笔
CPen* pPenBlack = new CPen; //创建画笔对象
pPenBlack->CreatePen(PS_SOLID, 1, RGB(0,0,0)); //黑色画笔
//选中黑色画笔,并保存当前画笔
CGdiObject* pOldPen = pDC->SelectObject(pPenBlack);
pDC->MoveTo(30,10); //绘制坐标轴
pDC->LineTo(30,nyLength-30); //垂直轴
pDC->LineTo(nxLength-10,nyLength-30); //水平轴
//横坐标箭头
pDC->MoveTo(nxLength-10-10,nyLength-30-3);
pDC->LineTo(nxLength-10,nyLength-30);
pDC->LineTo(nxLength-10-10,nyLength-30+3);
pDC->LineTo(nxLength-10-10,nyLength-30-3);
//纵坐标箭头
pDC->MoveTo(27,20);
pDC->LineTo(30,10);
pDC->LineTo(33,20);
pDC->LineTo(27,20);
//横坐标数字
nMeshLength = (nxLength-40)/(nxDivisionNumber+1);
for (i=0; i
str.Format("%d",i);
pDC->TextOut(27+i*nMeshLength, nyLength-27, str);
}
//横坐标标识
str.Format("时间");
pDC->TextOut(nxLength-33,nyLength-27,str);
//纵坐标数字
nMeshLength = (nyLength-40)/(nyDivisionNumber+1);
for (i=0; i
str.Format("%d",i*25);
pDC->TextOut(3, nyLength-40-i*nMeshLength, str);
}
//纵坐标标识
str.Format("直径");
pDC->TextOut(1,3,str);
//网格线
pDC->SelectObject(pPenBlue);
nMeshLength = (nxLength-40)/(nxDivisionNumber+1);
for (i=1; i
pDC->MoveTo(30+i*nMeshLength,nyLength-30);
pDC->LineTo(30+i*nMeshLength,10);
}
nMeshLength = (nyLength-40)/(nyDivisionNumber+1);
for (i=1; i
pDC->MoveTo(30,nyLength-30-i*nMeshLength);
pDC->LineTo(nxLength-10,nyLength-30-i*nMeshLength);
}
//////////////////////////////////////////////////////////////////////////
//*******画生长曲线图*******
//////////////////////////////////////////////////////////////////////////
//恢复以前的画笔
pDC->SelectObject(pOldPen);
delete pPenRed;
delete pPenGreen;
delete pPenBlue;
delete pPenBlack;
}