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

📄 bxtdlg.cpp

📁 CT工作站具有打印报告、病历管理、图像处理专家词库等功能
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		m_path	+= query->m_id;
	}
	m_path	+= "\\";
#endif

	bool	seled[MAX_PIC];
	CSelPic	selpic(m_path.GetBuffer(m_path.GetLength()),seled);

/*	-> DEBUGING
	AfxMessageBox("selpic.DoModal() - begin");
	int		result;
	char	buf2[10];
	if		(IDOK != (result = selpic.DoModal())) return;
	CString	msg;
	msg		= "selpic.DoModal() - end - [";
	msg		+= itoa(result,buf2,10);
	msg		+= "] IDOK = [";
	msg		+= itoa(IDOK,buf2,10);
	msg		+= "]";
	AfxMessageBox(msg);
*/

	selpic.DoModal();

	int		piccount;
	char	picpathname[12][200];
	piccount	= 0;

	for	(i = 0; i < MAX_PIC; i++)
	{
		if (seled[i])
		{
			sprintf(picpathname[piccount++],"%s%d.jpg",m_path.GetBuffer(m_path.GetLength()),i + 1);
			if (piccount >= ((printway == 0)?9:12)) break;
		}
	}

	CString text;

	// m_rich
	CRichEditCtrl *m_rich;

	if (iscurrentrecord)
		m_rich	= &(report->m_rich);
	else
		m_rich	= &(query->m_rich);
	
	// rows,cols
	int rows,cols;
	if (printway == 0)
	{
		rows	= 3;
		cols	= 3;
	}
	else
	{
		rows	= 4;
		cols	= 3;
	}
	
	// print dialog
	CPrintDialog pdlg(false);
	if (pdlg.DoModal() != IDOK)
		return;
	HDC hPrinterDC = pdlg.GetPrinterDC();

	// Pen, Color, Font, Print text
	CPen *oldpen;
#ifdef _DEBUG
	CPen rpen(PS_SOLID,1,RGB(255,0,0));
	CPen bpen(PS_SOLID,1,RGB(0,0,255));
#else
	CPen rpen(PS_SOLID,1,RGB(0,0,0));
	CPen bpen(PS_SOLID,1,RGB(0,0,0));
#endif
	CFont *oldfont;
	CFont font_title1,font_title2,font_text,font_info;

	COLORREF red,blue;
	CSize size;

	// Init Color
#ifdef _DEBUG
	red		= RGB(255,0,0);
	blue	= RGB(0,0,255);
#else
	red		= RGB(0,0,0);
	blue	= RGB(0,0,0);
#endif

	// Create dc
	CDC dc;
	dc.Attach(hPrinterDC);
	dc.m_bPrinting	= true;
	oldpen	= dc.SelectObject(&rpen);
	dc.SetTextColor(red);

	// Init Struct Memory
    DOCINFO di;
	memset(&di,0,sizeof(DOCINFO));

	//##
    di.cbSize = sizeof (DOCINFO);
    di.lpszDocName = "CT 报告单";

    //
	BOOL bprintingok;
	bprintingok = dc.StartDoc(&di);

	// Print Info
	CPrintInfo info;
	info.m_rectDraw.SetRect(0,0, 
                            dc.GetDeviceCaps(HORZRES), 
                            dc.GetDeviceCaps(VERTRES));

	// Get Width Height Ratio
	float ww = (float)dc.GetDeviceCaps(HORZRES);
	float hh = (float)dc.GetDeviceCaps(VERTRES);
	ww = (float)(ww / 2100.0);
	hh = (float)(hh / 2900.0);

	// Init Font
	font_title1.CreatePointFont(fontsize(60),"宋体");	// Title 1
	font_title2.CreatePointFont(fontsize(45),"宋体");	// Title 2
	font_text.CreatePointFont(fontsize(27),"楷体");		// Doc Font
	font_info.CreatePointFont(fontsize(15),"宋体");		// Info Font

	// Start Page
    dc.StartPage();

	// Begin Print Rich Edit Box -->
	FORMATRANGE fr;
	int	nHorizRes	= GetDeviceCaps(hPrinterDC, HORZRES);
	int	nVertRes	= GetDeviceCaps(hPrinterDC, VERTRES);
	int	nLogPixelsX	= GetDeviceCaps(hPrinterDC, LOGPIXELSX);
	int	nLogPixelsY	= GetDeviceCaps(hPrinterDC, LOGPIXELSY);

	LONG	lTextLength;   // Length of document.
	LONG	lTextPrinted;  // Amount of document printed.

	int	nHsize	= GetDeviceCaps(hPrinterDC, HORZSIZE);
	int	nVsize	= GetDeviceCaps(hPrinterDC, VERTSIZE);
	// Ensure the printer DC is in MM_TEXT mode.
	
	SetMapMode(hPrinterDC, MM_TEXT);
	//SetMapMode ( hPrinterDC, MM_TWIPS );
	// Rendering to the same DC we are measuring.
	
	memset(&fr,0,sizeof(fr));

	fr.hdc = fr.hdcTarget = hPrinterDC;
	// Set up the page.

	fr.rcPage.left     = fr.rcPage.top	= 0;
	fr.rcPage.right    = (nHorizRes/nLogPixelsX) * 1440;
	fr.rcPage.bottom   = (nVertRes/nLogPixelsY) * 1440;

	int mg	= 0;

//	fr.rc.left   = fr.rcPage.left	+ mg	+ cm2twip(1.2);
//	if (printway == 0)	// 3 X 3
//		fr.rc.top    = fr.rcPage.top	+ mg	+ cm2twip(19.4);
//	else				// 4 X 3
//		fr.rc.top    = fr.rcPage.top	+ mg	+ cm2twip(23.2);
//	fr.rc.right  = fr.rcPage.right	- mg	- cm2twip(1.2);
//	fr.rc.bottom = fr.rcPage.bottom	- mg;


	fr.rc.left   = cm2twip(1.2);
	if (printway == 0)	// 3 X 3
		fr.rc.top    = cm2twip(18.9);
	else				// 4 X 3
		fr.rc.top    = cm2twip(18.9 + 4.75);
	fr.rc.right  = cm2twip(18.6);
	fr.rc.bottom = cm2twip(27.5);

	// Default the range of text to print as the entire document.
	fr.chrg.cpMin	= 0;
	fr.chrg.cpMax	= -1;

	// Set up the print job (standard printing stuff here).
	// Find out real size of document in characters.
	//lTextLength = SendMessage ( /*hRTFWnd,*/ WM_GETTEXTLENGTH, 0, 0 );
	lTextLength	= m_rich->GetTextLength();
	
	CRect ccr;
	ccr.left	= fr.rc.left;
	ccr.right	= fr.rc.right;
	ccr.top		= fr.rc.top;
	ccr.bottom	= fr.rc.bottom;
	m_rich->SetTargetDevice(hPrinterDC,fr.rc.right);

	do	// Print Line Loop
	{
		lTextPrinted = m_rich->FormatRange(&fr);
		m_rich->DisplayBand(&ccr);
		if (lTextPrinted < lTextLength)
		{
			fr.chrg.cpMin = lTextPrinted;
			fr.chrg.cpMax = -1;
		}
	}while(lTextPrinted < lTextLength);
	// End Print Rich Edit Box <--

	// Print Blue Image
	dc.SelectObject(bpen);
	dc.SetTextColor(blue);

	// Title 1 Font
	oldfont	= dc.SelectObject(&font_title1);
	//	text	= "内蒙古伊克昭盟医院";


	if (iscurrentrecord)
		text	= geninfo->m_hospital;
	else
		text	= geninfo->m_hospital;

	size	= dc.GetTextExtent(text);
	dc.TextOut(midx(size.cx),ycm(1.0),text);

	// Title 2 Font
	dc.SelectObject(&font_title2);
	//	text	= "CT 检查报告单";
	if (iscurrentrecord)
		text	= "CT 检查报告单";
	else
		text	= "CT 检查报告单";
	size	= dc.GetTextExtent(text);
	dc.TextOut(midx(size.cx),ycm(2.0),text);

	dc.SelectObject(&font_text);
	//	text	= "CT 编号:2000072712345";
	text	= "CT 编号:";
	if (iscurrentrecord)
		text	+= geninfo->m_id;
	else
		text	+= query->m_id;
	dc.TextOut(xcm(1.0),ycm(2.1),text);

	//	text	= "住院号:12345";
	text	= "住院号:";
	if (iscurrentrecord)
		text	+= geninfo->m_hospid;
	else
		text	+= query->m_hospid;
	dc.TextOut(xcm(1.0),ycm(2.6),text);

	//	text	= "床号:12345";
	text	= "床号:";
	if (iscurrentrecord)
		text	+= geninfo->m_bedid;
	else
		text	+= query->m_bedid;
	dc.TextOut(xcm(16),ycm(2.1),text);

	//	text	= "科别:门 诊";
	text	= "科别:";
	if (iscurrentrecord)
		text	+= geninfo->m_class;
	else
		text	+= query->m_class;
	dc.TextOut(xcm(16),ycm(2.6),text);

	//	text	= "报告时间:2000年07月27日 21时11分21秒";
	text	= "报告时间:";
	CString secondformat	= "00秒";
	int		secondlen		= secondformat.GetLength();
	if (iscurrentrecord)
		text	+= geninfo->m_checkdate;
	else
		text	+= query->m_checkdate;
	text	= text.Left(text.GetLength() - secondlen);
#ifdef _DEBUG
	AfxMessageBox(text);
#endif
	dc.TextOut(xcm(1.0),ycm(28.2),text);

	//	text	= "诊断医师:齐学丰";
	text	= "诊断医师:";
	if (iscurrentrecord)
		text	+= report->m_doctor;
	else
		text	+= query->m_doctor;
	dc.TextOut(xcm(16),ycm(28.2),text);

	int left,top,right,bottom,width,height;

	left	= xcm(1);
	top		= ycm(3.0);
	right	= xcm(20);
	bottom	= ycm(28);
	dc.MoveTo(left,top);
	dc.LineTo(right,top);
	dc.LineTo(right,bottom);
	dc.LineTo(left,bottom);
	dc.LineTo(left,top);

	dc.MoveTo(left,ycm(3.6));
	dc.LineTo(right,ycm(3.6));

	dc.MoveTo(left,ycm(4.2));
	dc.LineTo(right,ycm(4.2));

	//	text	= "姓名:齐学丰";
	text	= "姓名:";
	if (iscurrentrecord)
		text	+= geninfo->m_name;
	else
		text	+= query->m_name;
	dc.TextOut(xcm(1.1),ycm(3.1),text);

	//	text	= "性别:男";
	text	= "性别:";
	if (iscurrentrecord)
		text	+= geninfo->m_sex;
	else
		text	+= query->m_sex;
	dc.TextOut(xcm(5.3),ycm(3.1),text);

	//	text	= "年龄:24";
	char buf[10];
	text	= "年龄:";
	if (iscurrentrecord)
		text	+= itoa(geninfo->m_age,buf,10);
	else
		text	+= itoa(query->m_age,buf,10);
	dc.TextOut(xcm(10.1),ycm(3.1),text);

	//	text	= "设备型号:UM9 DP";
	text	= "设备型号:";
	if (iscurrentrecord)
		text	+= geninfo->m_device;
	else
		text	+= query->m_device;
	dc.TextOut(xcm(14.8),ycm(3.1),text);

	//	text	= "检查类别:什么是检查类别?";
	text	= "检查类别:";
	if (iscurrentrecord)
		text	+= geninfo->m_checkstyle;
	else
		text	+= query->m_checkstyle;
	dc.TextOut(xcm(1.1),ycm(3.7),text);

	//	text	= "检查部位:";
	text	= "检查部位:";
	if (iscurrentrecord)
		text	+= geninfo->m_checkpos;
	else
		text	+= query->m_checkpos;
	dc.TextOut(xcm(10.1),ycm(3.7),text);

//	dc.TextOut(xcm(1.0),ycm(28.2),text);

	CString m_filepath,m_filename;
	m_filepath	= "e:\\";
	CPic pic;
	
	int thex,they;
	int bx,by,dx,dy;

//	rows	= 3;
//	cols	= 3;

	bx		= xcm(1.1);
	by		= ycm(4.3);
	width	= xcm(6.2);
	height	= ycm(4.65);
	dx		= xcm(6.3);
	dy		= ycm(4.75);

	for (j = 0; j < rows; j++)
	{
		for (i = 0; i < cols; i++)
		{
			if (j * cols + i + 1 > piccount) break;
			pic.loadjpgGry(picpathname[j * cols + i]);
			thex = bx + i * dx;
			they = by + j * dy;
			pic.DrawBMP(&dc,thex,they,width,height,0);

#ifdef _DEBUG
			dc.TextOut(thex,they,picpathname[j * cols + i]);
#endif
		}
	}

	dc.MoveTo(left, by + dy * rows);
	dc.LineTo(right,by + dy * rows);

	RECT rect;
	rect.left	= left		+ xcm(0.1);
	rect.top	= bottom	- ycm(2.0);
	rect.right	= right		- xcm(0.1);
	rect.bottom = bottom	- ycm(0.1);
	text	= "诊断结果:";
	if (iscurrentrecord)
		text	+= report->m_result;
	else
		text	+= query->m_result;
	dc.DrawText(text,&rect,DT_LEFT|DT_WORDBREAK);
		
	dc.SelectObject(&font_info);
	text	= "北京医学影象技术中心 BMIC医学影像工作站 TEL:010-64272093";
	size	= dc.GetTextExtent(text);
	dc.TextOut(midx(size.cx),ycm(28.2),text);

//	text	= "北京市朝阳区东土城路 8 号林达大厦 A 座 6E, 100000";
//	dc.TextOut(xcm(8.0),ycm(28.6),text);
	dc.SelectObject(oldpen);
	dc.SelectObject(oldfont);

	bprintingok = (dc.EndPage() > 0);
	if (bprintingok) 
		dc.EndDoc();  
	else
		dc.AbortDoc();                          // abort job.
	dc.Detach();                                // detach the printer dc	
}

void
CBxtDlg::OnOkx() 
{
	rec->CloseRecImage();
	CDialog::OnOK();	
}

void
CBxtDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
}

void
CBxtDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
{
}

⌨️ 快捷键说明

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