VC 做曲线 换颜色曲线不能显示的问题! 求帮忙!!谢~(问题用红色标注)
CWnd *pWnd=GetDlgItem(IDC_SRC);CDC *pDC=pWnd->GetDC();
pDC->Rectangle (0,0,400,300);
CPen* pPenGray1=new CPen;
pPenGray1->CreatePen (PS_DASH,1,RGB(128,128,128));//灰(网格 虚线)
CPen* pPenGray2=new CPen;
pPenGray2->CreatePen (PS_SOLID,1,RGB(128,128,128));//灰(网格)
CPen* pPenBlack=new CPen;
pPenBlack->CreatePen (PS_SOLID,2,RGB(0,0,0));//黑
CPen* pPenYellow=new CPen;
pPenYellow->CreatePen (PS_SOLID,2,RGB(250,250,66));//黄
CPen* pPenRed=new CPen;
pPenRed->CreatePen (PS_SOLID,1,RGB(240,50,5));//红
CGdiObject* pOldPen=pDC->SelectObject (pPenBlack);//绘制 坐标轴
pDC->MoveTo (20,10);
pDC->LineTo (20,280);
pDC->MoveTo (20,280);
pDC->LineTo (380,280);
CString sPIText[]={"0","5","10","15","20","25","30"};// 横轴坐标值
for(int i=0;i<7;i++)
{
pDC->MoveTo(50*i+20,280);
pDC->LineTo(50*i+20,275);
pDC->TextOut(50*i+15,282,sPIText[i]);
// pDC->TextOut(160,300,"前轴制动力");
}
CString sPIText1[]={"","5","10","15","20","25"};// 纵轴坐标值
for(int m=0,j=0;m<6;m++,j++)
{
pDC->MoveTo(20,280-j*50);
pDC->LineTo(25,280-j*50);
pDC->TextOut(3,280-j*50,sPIText1[m]);
//pDC->TextOut(0,120,"@后轴制动力");
}
pDC->SelectObject (pPenGray1);//绘制网格虚线
for(i=1;i<7;i++)
{
pDC->MoveTo(50*i+20,280);
pDC->LineTo(50*i+20,10);
}
for(j=1;j<6;j++)
{
pDC->MoveTo(20,280-j*50);
pDC->LineTo(380,280-j*50);
}
pDC->SelectObject (pPenGray2);//绘制网格实线
pDC->MoveTo (20,10);
pDC->LineTo (380,10);
pDC->MoveTo (380,10);
pDC->LineTo (380,280);
for(i=0;i<36;i++)// 绘制横坐标刻度
{
pDC->MoveTo(10*i+20,280);
pDC->LineTo(10*i+20,275);
}
for(j=0;j<28;j++)// 绘制纵坐标刻度
{
pDC->MoveTo(20,280-j*10);
pDC->LineTo(25,280-j*10);
}
pDC->SelectObject (pPenYellow);// 为什么这句中将 Yellow 换为 Red 就看不到曲线了??
for(i=70;i<113;i++)
{
y1=280-((i-20)+12.5);
pDC->MoveTo((int)i,(int)y1);
pDC->LineTo((int)i,(int)y1);
}
for(i=40;i<170;i++)
{
y1=280-((i-20)+17.5)/0.85;
pDC->MoveTo((int)i,(int)y1);
pDC->LineTo((int)i,(int)y1);
}