📄 bxtdlg.cpp
字号:
case 0:
rows = 3;
cols = 3;
break;
case 1:
rows = 4;
cols = 3;
break;
case 2:
rows = 1;
cols = 1;
break;
case 3:
rows = 1;
cols = 2;
break;
case 4:
rows = 2;
cols = 2;
break;
case 5:
rows = 2;
cols = 3;
break;
}
// 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 = "超声报告单";
//
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 = cm2twip(1.2);
switch (printway)
{
case 0: // 3 X 3
case 2: // 1 X 1
case 3: // 2 X 1
fr.rc.top = cm2twip(11);
break;
case 4: // 2 X 2
case 5:
//fr.rc.top = cm2twip(18.9);
fr.rc.top = cm2twip(11+3);
break;
case 1: // 4 X 3
//fr.rc.top = cm2twip(18.9 + 4.75);
fr.rc.top = cm2twip(11 + 4.75);
break;
}
fr.rc.right = cm2twip(18.6);
//fr.rc.bottom = cm2twip(27.5);
fr.rc.bottom = cm2twip(35.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 = "超声检查报告单";
else
text = "超声检查报告单";
size = dc.GetTextExtent(text);
dc.TextOut(midx(size.cx),ycm(2.0),text);
dc.SelectObject(&font_text);
// text = "CT 编号:2000072712345";
text = "超声编号:";
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);
switch (printway)
{
case 0: // 3 X 3
case 1: // 4 X 3
width = xcm(6.2);
height = ycm(4.65);
dx = xcm(6.3);
dy = ycm(4.75);
break;
case 2: // 1 X 1
bx += xcm(4.5);
width = xcm(9.3);
height = ycm(7.0);
dx = xcm(9.4);
dy = ycm(7.1);
break;
case 3: // 2 X 1
//bx = xcm(5.75);
width = xcm(9.3);
height = ycm(7.0);
dx = xcm(9.5);
dy = ycm(7.1);
break;
case 4: // 2 X 2
bx += xcm(2.1);
width = xcm(6.2);
height = ycm(4.65);
dx = xcm(6.2+2.1);
dy = ycm(4.75);
break;
case 5: // 3 X 2
//bx += xcm(5.1/4);
width = xcm(6.2);
height = ycm(4.65);
dx = xcm(6.3);
dy = ycm(4.75);
break;
}
for (j = 0; j < rows; j++)
{
for (i = 0; i < cols; i++)
{
if (j * cols + i + 1 > piccount) break;
pic.loadjpg(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);
rect.left = left + xcm(0.1);
rect.top = bottom - ycm(1.5);
rect.right = right - xcm(0.1);
rect.bottom = bottom - ycm(0.1);
text = "诊断结果:";
CFont font_result, font_result2;
font_result.CreatePointFont(fontsize(37), "楷体");
oldfont = dc.SelectObject(&font_result);
dc.TextOut(left + xcm(0.1), bottom - ycm(2.2), text);
dc.SelectObject(oldfont);
DeleteObject(&font_result);
if (iscurrentrecord)
text = report->m_result;
else
text = query->m_result;
font_result2.CreatePointFont(fontsize(30), "楷体");
oldfont = dc.SelectObject(&font_result2);
dc.DrawText(text, &rect, DT_LEFT | DT_WORDBREAK);
dc.SelectObject(oldfont);
DeleteObject(&font_result2);
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::OnTimer(UINT nIDEvent)
{
static int times=0;
if(nIDEvent==9)
{
times++;
if(times<5)
{
//m_m.SetCurSel(times);
m_m.SelectTab(times);
TabSelChange(IDC_TAB1,0);
}
else
{
m_m.SelectTab(0);
//m_m.HitTest()
TabSelChange(IDC_TAB1,0);
rec->ShowWindow(SW_SHOW);
//rec->SetDispMode();
KillTimer(9);
}
}
CDialog::OnTimer(nIDEvent);
}
void CBxtDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
}
void CBxtDlg::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
{
}
void CBxtDlg::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
if(rec)
delete rec;
if(xhelp)
delete xhelp;
if(query)
delete query;
if(report)
delete report;
if(imgpcs)
delete imgpcs;
if(geninfo)
delete geninfo;
if(reccing)
delete reccing;
if(recinforgb)
delete recinforgb;
if(querytime)
delete querytime;
if(queryfree)
delete queryfree;
if(queryorder)
delete queryorder;
if(queryname)
delete queryname;
if(helpref)
delete helpref;
if(helppic)
delete helppic;
if(helphelp)
delete helphelp;
if(dispimginfo)
delete dispimginfo;
if(rpttemplate)
delete rpttemplate;
if(dispzoom)
delete dispzoom;
if(printimage)
delete printimage;
if(dispprocess)
delete dispprocess;
if(dispmeasure)
delete dispmeasure;
if(dispmarking)
delete dispmarking;
if(dispconbri)
delete dispconbri;
CDialog::PostNcDestroy();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -