您好,欢迎访问三七文档
1/19VC++常用代码voidCDJJSView::bit1(CDC*pDC){CBitmapBitmap,*pOldBitmap;CDCMemDC;Bitmap.LoadBitmap(IDB_BIT1);MemDC.CreateCompatibleDC(pDC);pOldBitmap=MemDC.SelectObject(&Bitmap);pDC-BitBlt(0,-47,1024,768,&MemDC,0,0,SRCCOPY);MemDC.SelectObject(pOldBitmap);}voidCDJJSView::FillRect0(CDC*pDC,COLORREFcol,CPointpoint,intchd,intkd)//画窗口背景矩形性子函数{CBrushnewBrush(col);CBrush*poldBrush;poldBrush=pDC-SelectObject(&newBrush);pDC-FillRect(CRect(point.x,point.y,point.x+chd,point.y+kd),&newBrush);pDC-SelectObject(poldBrush);newBrush.DeleteObject();}voidCDJJSView::Line0(CDC*pDC,doublex1,doubley1,doublex2,doubley2,intsiw,COLORREFcol)//画实直线子函数{CPensiPen;CPen*pO1dPen;siPen.CreatePen(PS_SOLID,siw,col);pO1dPen=pDC-SelectObject(&siPen);2/19pDC-MoveTo(int(HI*x1),int(HI*y1));pDC-LineTo(int(HI*x2),int(HI*y2));pDC-SelectObject(pO1dPen);siPen.DeleteObject();}voidCDJJSView::quxian0(CDC*pDC)//转速--转矩坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Ne(r/min));for(j=0;j20;j++){x1+=6;ds+=150;Line0(pDC,x1/2,0,x1/2,35,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));}dsy=0;Line0(pDC,0,-5,0,35,4,RGB(0,0,0));pDC-TextOut(-110,int(HI*37),Me(N*m));for(j=0;j14;j++){y1+=5;dsy+=100;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));sc.Format(%3.1f,dsy);3/19pDC-TextOut(-110,int(HI*y1/2)+20,sc,strlen(sc));}}voidCDJJSView::quxian1(CDC*pDC)//转速--功率坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Ne(r/min));for(j=0;j20;j++){x1+=6;ds+=150;Line0(pDC,x1/2,0,x1/2,35,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));}dsy=0;Line0(pDC,0,-5,0,35,4,RGB(0,0,0));pDC-TextOut(-110,int(HI*37),Pe(KW));for(j=0;j14;j++){y1+=5;dsy+=15;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));sc.Format(%3.1f,dsy);pDC-TextOut(-110,int(HI*y1/2)+20,sc,strlen(sc));4/19}}voidCDJJSView::quxian2(CDC*pDC)//驱动力--行驶阻力坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Va(km/h));for(j=0;j12;j++){x1+=10;ds+=15;Line0(pDC,x1/2,0,x1/2,45,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));dsy=0;Line0(pDC,0,-5,0,45,4,RGB(0,0,0));pDC-TextOut(-150,int(HI*47),Ft(N));}for(j=0;j18;j++){y1+=5;dsy+=3000;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));5/19sc.Format(%3.1f,dsy);pDC-TextOut(-150,int(HI*y1/2)+20,sc,strlen(sc));}}voidCDJJSView::quxian3(CDC*pDC)//功率--车速图坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Va(km/h));for(j=0;j12;j++){x1+=10;ds+=15;Line0(pDC,x1/2,0,x1/2,35,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));}dsy=0;Line0(pDC,0,-5,0,35,4,RGB(0,0,0));pDC-TextOut(-110,int(HI*37),Pe(KW));for(j=0;j14;j++){y1+=5;dsy+=15;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));6/19sc.Format(%3.1f,dsy);pDC-TextOut(-110,int(HI*y1/2)+20,sc,strlen(sc));}}voidCDJJSView::quxian4(CDC*pDC)//动力因数曲线坐标系//{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Va(Km/h));for(j=0;j12;j++){x1+=10;ds+=15;Line0(pDC,x1/2,0,x1/2,40,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));dsy=0;Line0(pDC,0,-5,0,40,4,RGB(0,0,0));pDC-TextOut(-110,int(HI*42),D);}for(j=0;j4;j++){7/19y1+=20;dsy+=0.1;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));sc.Format(%3.1f,dsy);pDC-TextOut(-110,int(HI*y1/2)+20,sc,strlen(sc));}}voidCDJJSView::quxian5(CDC*pDC)//加速度倒数曲线坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Va(Km/h));for(j=0;j12;j++){x1+=10;ds+=15;Line0(pDC,x1/2,0,x1/2,42.5,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(int(HI*x1/2)-20,-10,buf,strlen(buf));dsy=0;Line0(pDC,0,-5,0,42.5,4,RGB(0,0,0));pDC-TextOut(-110,int(HI*45),1/a);}8/19for(j=0;j17;j++){y1+=5;dsy+=2;Line0(pDC,0,y1/2,60,y1/2,1,RGB(100,0,100));sc.Format(%3.1f,dsy);pDC-TextOut(-120,int(HI*y1/2)+20,sc,strlen(sc));}}voidCDJJSView::quxian6(CDC*pDC)//爬坡度--车速图坐标系{intj,ds;doublex1,y1,dsy;charbuf[25];CStringsc;pDC-SetBkColor(colb);ds=0;x1=0;y1=0;wsprintf(buf,%d,ds);pDC-TextOut(-40,-10,buf,strlen(buf));Line0(pDC,-5,0,60,0,4,RGB(0,0,0));pDC-TextOut(int(HI*58),-60,Va(Km/h));for(j=0;j12;j++){x1+=10;ds+=15;Line0(pDC,x1/2,0,x1/2,40,1,RGB(100,0,100));wsprintf(buf,%d,ds);pDC-TextOut(i
本文标题:VC--常用代码
链接地址:https://www.777doc.com/doc-5563733 .html