⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageprinter.cpp

📁 485通讯接口模块的编程应用
💻 CPP
📖 第 1 页 / 共 2 页
字号:
 	CDC dc;
 	CPrintDialog dlg(FALSE);
 	//选择打印机
 	/*if (dlg.DoModal()==IDOK)
 	{
 		AfxMessageBox("123");
 	}*/
 
 	//选择默认打印机
 	if (!dlg.GetDefaults())
 	{
 		AfxMessageBox("没有默认打印机");
 	}
 
 	dc.Attach(dlg.GetPrinterDC());
 
 	//dc.SetMapMode(MM_TEXT);
 	int iv=dc.GetDeviceCaps(VERTSIZE);
 	int ih=dc.GetDeviceCaps(HORZSIZE);

	CString strTime ;
	CTime time ;
	time = CTime::GetCurrentTime();
	strTime.Format("%d-%d-%d",time.GetYear(),time.GetMonth(),time.GetDay());
 
 	CString strValue="";
 	static DOCINFO di={sizeof(DOCINFO),"printer",NULL}; 
 	dc.StartDoc(&di);
 	dc.StartPage();
 	Draw_TextBB(dc,1600,300,"DK20发电机组台架试验记录");
 	
 	//综合
 	Draw_LineHB(dc,100,4650,500);
 	Draw_LineH(dc,100,4650,661);
 	Draw_LineH(dc,100,4650,822);
 	Draw_LineHB(dc,100,4650,983);
 	Draw_LineVB(dc,100,500,5974);
 	Draw_LineV(dc,1350,500,983);
 	Draw_LineV(dc,2858,500,983);
 	Draw_LineVB(dc,4650,500,5974);
 
 	Draw_TextB(dc , 152 , 552 ,"机    型:");
	Draw_TextB(dc , 700 , 552 ,"DK20");
 	Draw_TextB(dc , 152 , 713 ,"大气压力:");
	Draw_TextB(dc , 700 , 713 ,"1.0");
 	Draw_TextB(dc , 152 , 874 ,"运行开始时间:");

	strValue.Format("%d-%d-%d %d:%d:%d",tBeginTime.GetYear(),tBeginTime.GetMonth(),tBeginTime.GetDay(),tBeginTime.GetHour(),tBeginTime.GetMinute(),tBeginTime.GetSecond());
	Draw_TextB(dc , 660 , 874 ,strValue);//源
 	Draw_TextB(dc , 1355 , 552 ,"柴油机编号:");
	switch(iDK) {
	case 0:
		strValue = strIDN1;
		break;
	case 1:
		strValue = strIDN2;
		break;
	default:
		strValue = strIDN3;
	}
	Draw_TextB(dc , 1800 , 552 ,strValue);//源
 	Draw_TextB(dc , 1355 , 713 ,"环境湿度:");
	Draw_TextB(dc , 1800 , 713 ,"75");            //源
 	Draw_TextB(dc , 1355 , 874 ,"运行终止时间:");
	Draw_TextB(dc , 2000 , 874 ,"2008-5-5 10:10:10");//源
 	Draw_TextB(dc , 2870 , 552 ,"日    期:");
	Draw_TextB(dc , 3300 , 552 ,strTime);
 	Draw_TextB(dc , 2870 , 713 ,"环境温度:");
	CString strTEMP("");
	switch(iDK) {
	case 0:
		strTEMP.Format("%0.1f",fTEMP1);
		break;
	case 1:
		strTEMP.Format("%0.1f",fTEMP2);
		break;
	default:
		strTEMP.Format("%0.1f",fTEMP3);
	}
	Draw_TextB(dc , 3300 , 713 ,strTEMP);
 	Draw_TextB(dc , 2870 , 874 ,"记录时间:");
	strTime.Format("%d-%d-%d %d:%d:%d",time.GetYear(),time.GetMonth(),time.GetDay(),time.GetHour,time.GetMinute(),time.GetSecond()); ;
	Draw_TextB(dc , 3300 , 874 ,strTime);
 	Draw_TextB(dc , 1100 , 713 ,"KPa");
 	Draw_TextB(dc , 2600 , 713 ,"%");
 	Draw_TextB(dc , 4450 , 713 ,"℃");
 
 
 	//功率
 	Draw_LineH(dc,360,4650,1144);
 	Draw_LineHB(dc, 100 , 4650 , 1305) ;
 	Draw_LineV(dc , 360 , 983 , 5974 );
 	Draw_LineV(dc , 1184 , 983 , 5652 );
 	Draw_LineV(dc , 2033 , 983 , 5652 );
 	Draw_LineV(dc , 3330 , 983 , 5652 );
 	Draw_TextB(dc , 152 , 1100 , "功率");
 	Draw_TextB(dc , 412 , 1035 , "柴油机转速");
	Draw_TextBM(dc , 1210 , 1035 , moudle[5*iDK+3].vcorValue[5].iCurrentvalue);
 	Draw_TextB(dc , 2115 , 1035 , "负荷");
	Draw_TextB(dc , 3340 , 1035 , strPWR);
 	Draw_TextB(dc , 412 , 1196 , "机组有功功率");
 	Draw_TextB(dc , 2115 , 1196 , "机组无功功率");
 	
 	Draw_TextB(dc , 1843 , 1035 , "r/min");
 	Draw_TextB(dc , 4450 , 1035 , "%");
 	Draw_TextB(dc , 1843 , 1196 , "KW");
 	Draw_TextB(dc , 4450 , 1196 , "KW");
 
 
 	//调速器
 	Draw_LineH(dc , 360 , 4650 ,1466);
 	Draw_LineHB(dc , 100 , 4650 ,1627);
 	Draw_TextB(dc , 152 , 1370 , "调速");
 	Draw_TextB(dc , 170 , 1490 , "器");
 	Draw_TextB(dc , 412 , 1337 , "齿条反馈电流");
 	Draw_TextB(dc , 2085 , 1337 , "表显齿条格数");
 	Draw_TextB(dc , 412 , 1498 , "调速空气压力");
 	Draw_TextB(dc , 2085 , 1498 , "机旁齿条格数");
 	Draw_TextB(dc , 1843 , 1337 , "mA");
 	Draw_TextB(dc , 4450 , 1337 , "格");
 	Draw_TextB(dc , 1843 , 1498 , "Bar");
 	Draw_TextB(dc , 4450 , 1498 , "格");
 
 	//燃油
 	Draw_LineH(dc , 360 , 4650 ,1788);
 	Draw_LineH(dc , 360 , 4650 , 1949 );
 	Draw_LineH(dc , 360 , 4650 ,2110);
 	Draw_LineHB(dc , 100 , 4650 , 2271 );
 	Draw_TextB(dc , 152 , 1900 , "燃油");
 	Draw_TextB(dc , 412 , 1659 , "发动机前燃油温度");
 	Draw_TextB(dc , 2085 , 1659 , "耗油量");
 	Draw_TextB(dc , 412 , 1820 , "发动机进口压力");
	Draw_TextBM(dc , 1210 , 1820 , moudle[5*iDK+3].vcorValue[5].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 1820 , "泄漏量");
 	Draw_TextB(dc , 412 , 1981 , "发动机出口压力");
 	Draw_TextB(dc , 2085 , 1981 , "燃油消耗率");
 	
 	Draw_TextB(dc , 1843 , 1659 , "℃");
 	Draw_TextB(dc , 4450 , 1659 , "L/h");
 	Draw_TextB(dc , 1843 , 1820 , "Bar");
 	Draw_TextB(dc , 4400 , 1820 , "ml/min");
 	Draw_TextB(dc , 1843 , 1981 , "Bar");
 	Draw_TextB(dc , 4400 , 1981 , "g/KWh");
 
 	//增压空气
 	Draw_LineH(dc , 360 , 4650 ,2432);
 	Draw_LineHB(dc , 100 , 4650 , 2593 );
 	Draw_TextB(dc , 152 , 2333 , "增压");
 	Draw_TextB(dc , 152 , 2434 , "空气");
 	Draw_TextB(dc , 412 , 2323 , "空冷器前空气温度");
	Draw_TextBM(dc , 1210 , 1820 , moudle[5*iDK+1].vcorValue[8].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 2323 , "空冷器前空气压力");
 	Draw_TextB(dc , 412 , 2464 , "空冷器后空气温度");
	Draw_TextBM(dc , 3340 , 2464 , moudle[5*iDK+1].vcorValue[9].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 2464 , "空冷器后空气压力");
 
 	Draw_TextB(dc , 1843 , 2323 , "℃");
 	Draw_TextB(dc , 4450 , 2323 , "Bar");
 	Draw_TextB(dc , 1843 , 2464 , "℃");
 	Draw_TextB(dc , 4450 , 2464 , "Bar");
 
 
 	//排气
 	Draw_LineH(dc , 360 , 4650 ,2915);
 	Draw_LineH(dc , 360 , 4650 , 3237 );
 	Draw_LineH(dc , 360 , 4650 ,3398);
 	Draw_LineH(dc , 360 , 4650 ,3559);
 	Draw_LineH(dc , 360 , 4650 , 3720 );
 	Draw_LineHB(dc , 100 , 4650 , 4042 );
 	Draw_LineH(dc , 2033 , 4650 ,2754);
 	Draw_LineH(dc , 2033 , 4650 ,3076);
 	Draw_LineV(dc , 2292 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 2551 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 2810 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 3069 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 3589 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 3848 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 4107 , 2593 , 3237 ) ;
 	Draw_LineV(dc , 1840 , 3237 , 5652 ) ;
 	Draw_LineV(dc , 4440 , 3237 , 5652 ) ;
 	Draw_TextB(dc , 152 , 3400 , "排气");
	float fAverage = 0 ;
	for (int i = 0 ; i < 8 ; i++ )
	{
		fAverage += moudle[5*iDK+1].vcorValue[i].iCurrentvalue;
	}
	fAverage = fAverage/8 ;
 	Draw_TextB(dc , 412 , 2675 , "各缸排气温度");
 	Draw_TextB(dc , 412 , 2786 , "平均值℃");
	Draw_TextBM(dc , 1210 , 2700 , fAverage);
 	Draw_TextB(dc , 412 , 2997 , "各缸爆炸压力");
 	Draw_TextB(dc , 412 , 3108 , "平均值MPa");
 	Draw_TextB(dc , 412 , 3269 , "增压器前排气温度");
 	Draw_TextB(dc , 412 , 3430 , "增压器后排气温度");
 	Draw_TextB(dc , 412 , 3591 , "增压器吸气真空度");
 	Draw_TextB(dc , 2085 , 3269 , "增压器转速");
	Draw_TextBM(dc , 3340 , 3269 , moudle[5*iDK+2].vcorValue[5].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 3430 , "排气背压");
 	Draw_TextB(dc , 2085 , 3591 , "烟度");
 	Draw_TextB(dc , 412 , 3772 , "增压器进口");
 	Draw_TextB(dc , 412 , 3883 , "废气压力");
 	Draw_TextB(dc , 2085 , 3772 , "增压器出口");
 	Draw_TextB(dc , 2085 , 3883 , "废气压力");
 	Draw_TextB(dc , 2095 , 2635 , "A1");
	Draw_TextBM(dc , 2040 , 2796 , moudle[5*iDK+1].vcorValue[0].iCurrentvalue);
 	Draw_TextB(dc , 2095 , 2957 , "A1");
 	Draw_TextB(dc , 2354 , 2635 , "A2");
	Draw_TextBM(dc , 2300 , 2796 , moudle[5*iDK+1].vcorValue[1].iCurrentvalue);
 	Draw_TextB(dc , 2354 , 2957 , "A2");
 	Draw_TextB(dc , 2613 , 2635 , "A3");
	Draw_TextBM(dc , 2556 , 2796 , moudle[5*iDK+1].vcorValue[2].iCurrentvalue);
 	Draw_TextB(dc , 2613 , 2957 , "A3");
 	Draw_TextB(dc , 2872 , 2635 , "A4");
	Draw_TextBM(dc , 2815 , 2796 , moudle[5*iDK+1].vcorValue[3].iCurrentvalue);
 	Draw_TextB(dc , 2872 , 2957 , "A4");
 	Draw_TextB(dc , 3131 , 2635 , "A5");
	Draw_TextBM(dc , 3075 , 2796 , moudle[5*iDK+1].vcorValue[4].iCurrentvalue);
 	Draw_TextB(dc , 3131 , 2957 , "A5");
 	Draw_TextB(dc , 3392 , 2635 , "A6");
	Draw_TextBM(dc , 3335 , 2796 , moudle[5*iDK+1].vcorValue[5].iCurrentvalue);
 	Draw_TextB(dc , 3392 , 2957 , "A6");
 	Draw_TextB(dc , 3651 , 2635 , "A7");
	Draw_TextBM(dc , 3595 , 2796 , moudle[5*iDK+1].vcorValue[6].iCurrentvalue);
 	Draw_TextB(dc , 3651 , 2957 , "A7");
 	Draw_TextB(dc , 3910 , 2635 , "A8");
	Draw_TextBM(dc , 3853 , 2796 , moudle[5*iDK+1].vcorValue[7].iCurrentvalue);
 	Draw_TextB(dc , 3910 , 2957 , "A8");
 	Draw_TextB(dc , 1843 , 3269 , "℃");
 	Draw_TextB(dc , 1843 , 3430 , "℃");
 	Draw_TextB(dc , 1843 , 3591 , "KPa");
 	Draw_TextB(dc , 4450 , 3269 , "r/min");
 	Draw_TextB(dc , 4450 , 3430 , "KPa");
 	Draw_TextB(dc , 4450 , 3591 , "SZ");
 	Draw_TextB(dc , 1843 , 3822 , "Bar");
 	Draw_TextB(dc , 4450 , 3822 , "KPa");
 	
 
 	//滑油
 	Draw_LineH(dc , 360 , 4650 ,4203);
 	Draw_LineH(dc , 360 , 4650 , 4364 );
 	Draw_LineHB(dc , 100 , 4650 , 4525 );
 	Draw_TextB(dc , 152 , 4235 , "滑油");
 	Draw_TextB(dc , 412 , 4074 , "滑油进机温度");
	Draw_TextBM(dc , 1210 , 4074 , moudle[5*iDK].vcorValue[2].iCurrentvalue);
 	Draw_TextB(dc , 412 , 4235 , "滑油进机压力");
	Draw_TextBM(dc , 1210 , 4235 , moudle[5*iDK+2].vcorValue[7].iCurrentvalue);
 	Draw_TextB(dc , 412 , 4396 , "曲轴箱压力");
 	Draw_TextB(dc , 2085 , 4074 , "增压器滑油滤器压差");
	Draw_TextBM(dc , 3340 , 4074 , moudle[5*iDK+3].vcorValue[0].iCurrentvalue);
 
 	Draw_TextB(dc , 1843 , 4074 , "℃");
 	Draw_TextB(dc , 1843 , 4235 , "Bar");
 	Draw_TextB(dc , 1843 , 4396 , "KPa");
 	Draw_TextB(dc , 4450 , 4074 , "Bar");
 
 
 
 	//海水
 	Draw_LineH(dc , 360 , 4650 , 4686 );
 	Draw_LineHB(dc , 100 , 4650 , 4847 );
 	Draw_TextB(dc , 152 , 4600 , "海水");
 	Draw_TextB(dc , 412 , 4557 , "低温水进机温度");
	Draw_TextBM(dc , 1210 , 4557 , moudle[5*iDK].vcorValue[1].iCurrentvalue);
 	Draw_TextB(dc , 412 , 4718 , "低温水进机压力");
	Draw_TextBM(dc , 1210 , 4718 , moudle[5*iDK+3].vcorValue[4].iCurrentvalue);
 
 	Draw_TextB(dc , 1843 , 4557 , "℃");
 	Draw_TextB(dc , 1843 , 4718 , "Bar");
 
 
 	//淡水
 	Draw_LineH(dc , 360 , 4650 , 5008 );
 	Draw_LineHB(dc , 100 , 4650 , 5169 );
 	Draw_TextB(dc , 152 , 4980 , "淡水");
 	Draw_TextB(dc , 412 , 4879 , "冷却水进机压力");
	Draw_TextBM(dc , 1210 , 4879 , moudle[5*iDK+2].vcorValue[6].iCurrentvalue);
 	Draw_TextB(dc , 412 , 5040 , "冷却水进机温度");
	//Draw_TextBM(dc , 1210 , 5040 , moudle[5*iDK+3].vcorValue[4].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 4879 , "冷却水出机压力");
	//Draw_TextBM(dc , 3340 , 4879 , moudle[5*iDK+3].vcorValue[4].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 5040 , "冷却水出机温度");
	Draw_TextBM(dc , 3340 , 5040 , moudle[5*iDK].vcorValue[0].iCurrentvalue);
 
 	Draw_TextB(dc , 1843 , 4879 , "Bar");
 	Draw_TextB(dc , 1843 , 5040 , "℃");
 	Draw_TextB(dc , 4450 , 4879 , "Bar");
 	Draw_TextB(dc , 4450 , 5040 , "℃");
 
 	//发电机
 	Draw_LineH(dc , 360 , 4650 ,5330);
 	Draw_LineH(dc , 360 , 4650 , 5491 );
 	Draw_LineHB(dc , 100 , 4650 , 5652 );
 	Draw_TextB(dc , 152 , 5300 , "发电");
 	Draw_TextB(dc , 170 , 5400 , "机");
 	Draw_TextB(dc , 412 , 5201 , "U相定子绕组温度");
	Draw_TextBM(dc , 1210 , 5201 , moudle[5*iDK+2].vcorValue[2].iCurrentvalue);
 	Draw_TextB(dc , 412 , 5362 , "V相定子绕组温度");
	Draw_TextBM(dc , 1210 , 5362 , moudle[5*iDK+2].vcorValue[3].iCurrentvalue);
 	Draw_TextB(dc , 412 , 5523 , "W相定子绕组温度");
	Draw_TextBM(dc , 1210 , 5523 , moudle[5*iDK+2].vcorValue[4].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 5201 , "发电机前轴承温度");
	Draw_TextBM(dc , 3340 , 5201 , moudle[5*iDK+2].vcorValue[0].iCurrentvalue);
 	Draw_TextB(dc , 2085 , 5362 , "发电机后轴承温度");
	Draw_TextBM(dc , 3340 , 5362 , moudle[5*iDK+2].vcorValue[1].iCurrentvalue);
 	Draw_TextB(dc , 1843 , 5201 , "℃");
 	Draw_TextB(dc , 1843 , 5362 , "℃");
 	Draw_TextB(dc , 1843 , 5523 , "℃");
 	Draw_TextB(dc , 4450 , 5201 , "℃");
 	Draw_TextB(dc , 4450 , 5362 , "℃");
 	
 
 	//轴承
 	Draw_LineH(dc , 360 , 4650 , 5813 );
 	Draw_LineHB(dc , 100 , 4650 , 5974 );
 	Draw_LineV(dc , 760 , 5652 , 5974 );
 	Draw_LineV(dc , 1255 , 5652 , 5974 );
 	Draw_LineV(dc , 1750 , 5652 , 5974 );
 	Draw_LineV(dc , 2245 , 5652 , 5974 );
 	Draw_LineV(dc , 2740 , 5652 , 5974 );
 	Draw_LineV(dc , 3235 , 5652 , 5974 );
 	Draw_LineV(dc , 3730 , 5652 , 5974 );
 	Draw_LineV(dc , 4225 , 5652 , 5974 );
 	Draw_LineV(dc , 4720 , 5652 , 5974 );
 	Draw_TextB(dc , 152 , 5700 , "轴承");
 	Draw_TextB(dc , 170 , 5815 , "℃");
 	Draw_TextB(dc , 510 , 5694 , "1档");
 	Draw_TextB(dc , 912 , 5694 , "2档");
 	Draw_TextB(dc , 1407 , 5694 , "3档");
 	Draw_TextB(dc , 1902 , 5694 , "4档");
 	Draw_TextB(dc , 2397 , 5694 , "5档");
 	Draw_TextB(dc , 2892 , 5694 , "6档");
 	Draw_TextB(dc , 3394 , 5694 , "7档");
 	Draw_TextB(dc , 3882 , 5694 , "8档");
 	Draw_TextB(dc , 4357 , 5694 , "9档");
 
 	Draw_TextB(dc , 320 , 5990 , "检验员:") ;
 	Draw_TextB(dc , 1800 , 5990 , "军(船)代表:") ;
 	Draw_TextB(dc , 3300 , 5990 , "日期:") ;
 	
 	
 	RestoreDC(dc,-1);
 	dc.EndPage();
 	dc.EndDoc();
 	MessageBox("打印完毕!","提示",MB_ICONINFORMATION);
 	DeleteDC(dc);
 }




void CPagePrinter::Draw_TextBM(HDC hdcPro, int x, int y , float fValue)
{
	HGDIOBJ font=SelectObject(hdcPro,CreateFont(
		90,                        // nHeight
		0,                         // nWidth
		0,                         // nEscapement
		0,                         // nOrientation
		FW_NORMAL,                 // nWeight
		FALSE,                     // bItalic
		FALSE,                     // bUnderline
		0,                         // cStrikeOut
		ANSI_CHARSET,              // nCharSet
		OUT_DEFAULT_PRECIS,        // nOutPrecision
		CLIP_DEFAULT_PRECIS,       // nClipPrecision
		DEFAULT_QUALITY,           // nQuality
		DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
		_T("Arial")));

	CString s("");
	s.Format("%.1f",fValue);
	TextOut(hdcPro,x,y,s,strlen(s));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -