Teminator 自己看别人看了没用
来源:互联网 发布:suse linux 安装mysql 编辑:程序博客网 时间:2024/04/28 21:27
20150630-OK版本
BOOL CTeminatorDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
// TODO: Add your message handler code here and/or call default
/*g_Log.Debug(_T("开始执行"));*/
//AfxMessageBox( _T("开始执行") );
CString strPrintDcmPath = _T(""); //转换成bmp的打印DCM图像路径
CString strFileSize= _T(""); //转换成bmp的打印DCM的胶片尺寸;
CString strHengDaFlag = _T("");
if (pCopyDataStruct != NULL)
{
//strPrintDcmPath = (LPWSTR)(pCopyDataStruct->lpData);
strPrintDcmPath = (LPCTSTR)(pCopyDataStruct->lpData);
if (_T("") == strPrintDcmPath)
{
//AfxMessageBox( _T("路径空") );
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
g_Log.Debug(strPrintDcmPath);
}
CString strBmpName; //生成的BMP图像名
//strPrintDcmPath = _T("D:\\printdir\\2015-05-31\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.2632.2015053115570854\\1.2.826.0.1.3680043.2.42.251101155961744.2632.2015053115570855\\FILMBOX-2.bmp|14INX17IN|LANDSCAPE|");
//strPrintDcmPath = _T("6|7|d:\\printdir\\2015-06-02\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.0408.20150602132633164\\1.2.826.0.1.3680043.2.42.251101155961744.0408.20150602132633165|14INX17IN|PORTRAIT|");
strPrintDcmPath = _T("3|4|d:\\printdir\\2015-06-02\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.0408.2015060219074847\\1.2.826.0.1.3680043.2.42.251101155961744.0408.2015060219074848|14INX17IN|PORTRAIT|");//PORTRAIT
vector <CString> vecMessage;
NormalMessageVector(strPrintDcmPath, &vecMessage);
//AfxMessageBox(strPrintDcmPath);
for (int i = 0; i < 1; i++)
{
//strPrintDcmPath = _T("D:\\printdir\\14_17_1430889894_5\\14_17_1430889894_5.dcm"); //灰度
//strPrintDcmPath = _T("D:\\printdir\\14_17_1431651859_1\\14_17_1431651859_1.dcm");//彩色
//strPrintDcmPath = _T("D:\\printdir\\1.2.826.0.1.3680043.2.42.1102738509824.7176.201505151436592.dcm");//wc合成图
//strPrintDcmPath = _T("D:\\printdir\\1.2.826.0.1.3680043.2.42.18398468180992.2388.201505181849180.dcm");
//加载DCM图像
//strPrintDcmPath = _T("3|4|d:\\printdir\\2015-05-27\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.4884.2015052718412914\\1.2.826.0.1.3680043.2.42.251101155961744.4884.2015052718412915|14INX17IN|");
BSTR strMergerBmpPath;
if (strPrintDcmPath.Find(_T("|")) >= 0 && vecMessage.size() > 3)
{
m_dicomDp->MergerPrintBmp(_bstr_t(strPrintDcmPath),_bstr_t(m_StrBmpFloder),&strMergerBmpPath);
strPrintDcmPath = strMergerBmpPath;
strHengDaFlag = vecMessage.at(4);
strFileSize = vecMessage.at(3);
}
else
{
strPrintDcmPath = vecMessage.at(0);
strFileSize = vecMessage.at(1);
strHengDaFlag = vecMessage.at(2);
}
BOOL bExist = ::PathFileExists(strPrintDcmPath);
if (!bExist)
{
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
if (strHengDaFlag == _T("LANDSCAPE") && vecMessage.size() <= 3 )
{
m_dicomDp->LoadDicomFile(_bstr_t(strPrintDcmPath));
m_dicomDp->RotateBmpPixel(_bstr_t(strPrintDcmPath));
m_dicomDp->ReleaseDicomFile();
}
//获取DCM的数据行数
m_dicomDp->LoadDicomFile(_bstr_t(strPrintDcmPath));
int nImageLine = 0;
int nImageCloumn = 0;
m_dicomDp->raw_GetColumnAndRow(&nImageCloumn,&nImageLine);
//获取时分秒
CString strDateTime;
CTime Tm=CTime::GetCurrentTime();
int nYear,nMonth,nDay,nHour,nMinute,nSecond,nMinSecond;
nYear=Tm.GetYear();
nMonth=Tm.GetMonth();
nDay=Tm.GetDay();
nHour=Tm.GetHour();
nMinute=Tm.GetMinute();
nSecond=Tm.GetSecond();
CString mSecond;
struct _timeb timebuffer1;
_ftime(&timebuffer1);
mSecond.Format(_T("%d"),timebuffer1.millitm);
nMinSecond=atoi(mSecond);
strDateTime.Format(_T("%04d_%02d_%02d_%02d_%02d_%02d_%03d"),nYear,nMonth,nDay,nHour,
nMinute,nSecond,nMinSecond);
//CString strBmpName; //生成的BMP图像名
strBmpName.Format(_T("%s\\%s"),m_StrBmpFloder,strDateTime);
m_strPaperType = g_Cfg.GetValue(_T("FilmSize"),strFileSize);
m_nDstWidth = g_Cfg.GetValueI(m_strPaperType, _T("nDstWidth"));
m_nDstHeight = g_Cfg.GetValueI(m_strPaperType, _T("nDstHeight"));
m_strBmpPrinterName = g_Cfg.GetValue(m_strPaperType, _T("PrinterName"));
//设置默认打印机
::SetDefaultPrinter(m_strBmpPrinterName);
//执行打印
CDC printDC;
CPrintDialog printDlg(FALSE);
DOCINFO docInfo;
if (printDlg.GetDefaults())
{
HDC hDC;
hDC=printDlg.GetPrinterDC();
if(!printDC.Attach(hDC))
{
return false;
}
}
else
{
printDC.Detach();
return false;
}
memset(&docInfo,0,sizeof(docInfo));
docInfo.cbSize=sizeof(DOCINFO);
docInfo.lpszDocName="Print Window";
if(printDC.StartDoc(&docInfo)<=0)
{
#ifdef _DEBUG
AfxMessageBox("Start Doc Failed");
return false;
#endif
printDC.Detach();
return false;
}
printDC.StartPage();
printDC.SetMapMode(MM_TEXT);
int nScaledWidth=printDC.GetDeviceCaps(HORZRES); //目标DC宽
int nScaledHeight=printDC.GetDeviceCaps(VERTRES);//目标DC高
//生成BMP图像打印
//A4纸是210mm×297mm大""按1英寸=25.4毫米换算,那么A4纸大约是8.2英寸*11.6英寸" 2360*3480
//A3纸是297mm×420mm,对角线大概长514.4mm,按1英寸=25.4毫米换算,那么A3纸大约是11.6英寸*16.5英寸" 3380*4950
m_nDstWidth = nScaledWidth;
m_nDstHeight = nScaledHeight;
int nRet = m_dicomDp->SaveDcmToZoomBmp(nImageCloumn,nImageLine,m_nDstWidth,m_nDstHeight,_bstr_t(strBmpName),IMG_BMP);
m_dicomDp->ReleaseDicomFile();
strBmpName.AppendFormat(_T(".bmp"));
g_Log.Debug(strBmpName);
//ShellExecute(NULL,_T("print"),strBmpName,_T(""),_T(""), SW_HIDE);
//return FALSE;
CDC dcMemory;
dcMemory.CreateCompatibleDC(&printDC);
HBITMAP m_hPrintBitmap;
PBITMAPINFO pBitmapInfo1 = CreateHPBITMAPINFO(nScaledWidth, nScaledHeight, false, false) ;
CDC dcMemory1;
dcMemory1.CreateCompatibleDC(NULL/*&Viewdc*/);
BYTE* pBmpBits1 = NULL;
m_hPrintBitmap = CreateDIBSection(dcMemory1.GetSafeHdc(), pBitmapInfo1, DIB_RGB_COLORS, (void**)&pBmpBits1, NULL, NULL);
memset(pBmpBits1,0,nScaledWidth*nScaledHeight*3);
CBitmap* bkBitmap =CBitmap().FromHandle(m_hPrintBitmap);
CBitmap* pOldBitmap= dcMemory.SelectObject(bkBitmap);
HBITMAP m_hBitmap;
m_hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle(),
strBmpName,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION );
if (m_hBitmap == NULL)
{
DeleteObject(m_hPrintBitmap);
DeleteObject(m_hBitmap);
AfxMessageBox(_T("LoadImage失败!"));
return false;
}
CBitmap bmp;
bmp.Attach( m_hBitmap );
CDC memDC;
memDC.CreateCompatibleDC(&printDC);
memDC.SelectObject(&bmp);
BITMAP BitInfo;
bmp.GetBitmap(&BitInfo);
int nBmpWidth = BitInfo.bmWidth;
int nBmpHeight = BitInfo.bmHeight;
//SaveBmp(m_hBitmap,_T("e:\\printdir\\222.bmp"));
//printDC.StretchBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0,nBmpWidth,nBmpHeight, SRCCOPY);
//if (printDC != NULL)
//{
// printDC.SetBkMode(OPAQUE);
// printDC.SetBkColor(RGB(0,0,0));
// printDC.SetTextColor(RGB(255,255,255));
//}
dcMemory.BitBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0, SRCCOPY);
//dcMemory.SetPixel(0,0,RGB(255,0,0));
//dcMemory.SetPixel(0,1,RGB(255,0,0));
//dcMemory.Draw3dRect(0,0,500,500,RGB(0,255,0),RGB(0,255,0));
//dcMemory.TextOut(nScaledWidth/2,100,_T("医疗信息技术有限公司"
printDC.BitBlt(0,0,nScaledWidth,nScaledHeight,&dcMemory,0,0, SRCCOPY);
//printDC.StretchBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0,nBmpWidth,nBmpHeight, SRCCOPY);
CString strDCBmpPath;
strDCBmpPath.Format(_T("%s\\DC_%s.bmp"),m_StrBmpFloder,strDateTime);
SaveBmp(m_hPrintBitmap,strDCBmpPath);
printDC.EndPage();
printDC.EndDoc();
printDC.Detach();
DeleteObject(m_hPrintBitmap);
DeleteObject(m_hBitmap);
DeleteObject(bmp);
dcMemory.DeleteDC();
memDC.DeleteDC();
printDC.DeleteDC();
g_Log.Debug(_T("执行打印完毕"));
//CoUninitialize();//释放COM
}
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
//
BOOL CTeminatorDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
// TODO: Add your message handler code here and/or call default
/*g_Log.Debug(_T("开始执行"));*/
//AfxMessageBox( _T("开始执行") );
CString strPrintDcmPath = _T(""); //转换成bmp的打印DCM图像路径
CString strFileSize= _T(""); //转换成bmp的打印DCM的胶片尺寸;
CString strHengDaFlag = _T("");
if (pCopyDataStruct != NULL)
{
//strPrintDcmPath = (LPWSTR)(pCopyDataStruct->lpData);
strPrintDcmPath = (LPCTSTR)(pCopyDataStruct->lpData);
if (_T("") == strPrintDcmPath)
{
//AfxMessageBox( _T("路径空") );
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
g_Log.Debug(strPrintDcmPath);
}
CString strBmpName; //生成的BMP图像名
//strPrintDcmPath = _T("D:\\printdir\\2015-05-31\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.2632.2015053115570854\\1.2.826.0.1.3680043.2.42.251101155961744.2632.2015053115570855\\FILMBOX-2.bmp|14INX17IN|LANDSCAPE|");
//strPrintDcmPath = _T("6|7|d:\\printdir\\2015-06-02\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.0408.20150602132633164\\1.2.826.0.1.3680043.2.42.251101155961744.0408.20150602132633165|14INX17IN|PORTRAIT|");
strPrintDcmPath = _T("3|4|d:\\printdir\\2015-06-02\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.0408.2015060219074847\\1.2.826.0.1.3680043.2.42.251101155961744.0408.2015060219074848|14INX17IN|PORTRAIT|");//PORTRAIT
vector <CString> vecMessage;
NormalMessageVector(strPrintDcmPath, &vecMessage);
//AfxMessageBox(strPrintDcmPath);
for (int i = 0; i < 1; i++)
{
//strPrintDcmPath = _T("D:\\printdir\\14_17_1430889894_5\\14_17_1430889894_5.dcm"); //灰度
//strPrintDcmPath = _T("D:\\printdir\\14_17_1431651859_1\\14_17_1431651859_1.dcm");//彩色
//strPrintDcmPath = _T("D:\\printdir\\1.2.826.0.1.3680043.2.42.1102738509824.7176.201505151436592.dcm");//wc合成图
//strPrintDcmPath = _T("D:\\printdir\\1.2.826.0.1.3680043.2.42.18398468180992.2388.201505181849180.dcm");
//加载DCM图像
//strPrintDcmPath = _T("3|4|d:\\printdir\\2015-05-27\\WANGCONG\\1.2.826.0.1.3680043.2.42.251101155961744.4884.2015052718412914\\1.2.826.0.1.3680043.2.42.251101155961744.4884.2015052718412915|14INX17IN|");
BSTR strMergerBmpPath;
if (strPrintDcmPath.Find(_T("|")) >= 0 && vecMessage.size() > 3)
{
m_dicomDp->MergerPrintBmp(_bstr_t(strPrintDcmPath),_bstr_t(m_StrBmpFloder),&strMergerBmpPath);
strPrintDcmPath = strMergerBmpPath;
strHengDaFlag = vecMessage.at(4);
strFileSize = vecMessage.at(3);
}
else
{
strPrintDcmPath = vecMessage.at(0);
strFileSize = vecMessage.at(1);
strHengDaFlag = vecMessage.at(2);
}
BOOL bExist = ::PathFileExists(strPrintDcmPath);
if (!bExist)
{
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
if (strHengDaFlag == _T("LANDSCAPE") && vecMessage.size() <= 3 )
{
m_dicomDp->LoadDicomFile(_bstr_t(strPrintDcmPath));
m_dicomDp->RotateBmpPixel(_bstr_t(strPrintDcmPath));
m_dicomDp->ReleaseDicomFile();
}
//获取DCM的数据行数
m_dicomDp->LoadDicomFile(_bstr_t(strPrintDcmPath));
int nImageLine = 0;
int nImageCloumn = 0;
m_dicomDp->raw_GetColumnAndRow(&nImageCloumn,&nImageLine);
//获取时分秒
CString strDateTime;
CTime Tm=CTime::GetCurrentTime();
int nYear,nMonth,nDay,nHour,nMinute,nSecond,nMinSecond;
nYear=Tm.GetYear();
nMonth=Tm.GetMonth();
nDay=Tm.GetDay();
nHour=Tm.GetHour();
nMinute=Tm.GetMinute();
nSecond=Tm.GetSecond();
CString mSecond;
struct _timeb timebuffer1;
_ftime(&timebuffer1);
mSecond.Format(_T("%d"),timebuffer1.millitm);
nMinSecond=atoi(mSecond);
strDateTime.Format(_T("%04d_%02d_%02d_%02d_%02d_%02d_%03d"),nYear,nMonth,nDay,nHour,
nMinute,nSecond,nMinSecond);
//CString strBmpName; //生成的BMP图像名
strBmpName.Format(_T("%s\\%s"),m_StrBmpFloder,strDateTime);
m_strPaperType = g_Cfg.GetValue(_T("FilmSize"),strFileSize);
m_nDstWidth = g_Cfg.GetValueI(m_strPaperType, _T("nDstWidth"));
m_nDstHeight = g_Cfg.GetValueI(m_strPaperType, _T("nDstHeight"));
m_strBmpPrinterName = g_Cfg.GetValue(m_strPaperType, _T("PrinterName"));
//设置默认打印机
::SetDefaultPrinter(m_strBmpPrinterName);
//执行打印
CDC printDC;
CPrintDialog printDlg(FALSE);
DOCINFO docInfo;
if (printDlg.GetDefaults())
{
HDC hDC;
hDC=printDlg.GetPrinterDC();
if(!printDC.Attach(hDC))
{
return false;
}
}
else
{
printDC.Detach();
return false;
}
memset(&docInfo,0,sizeof(docInfo));
docInfo.cbSize=sizeof(DOCINFO);
docInfo.lpszDocName="Print Window";
if(printDC.StartDoc(&docInfo)<=0)
{
#ifdef _DEBUG
AfxMessageBox("Start Doc Failed");
return false;
#endif
printDC.Detach();
return false;
}
printDC.StartPage();
printDC.SetMapMode(MM_TEXT);
int nScaledWidth=printDC.GetDeviceCaps(HORZRES); //目标DC宽
int nScaledHeight=printDC.GetDeviceCaps(VERTRES);//目标DC高
//生成BMP图像打印
//A4纸是210mm×297mm大""按1英寸=25.4毫米换算,那么A4纸大约是8.2英寸*11.6英寸" 2360*3480
//A3纸是297mm×420mm,对角线大概长514.4mm,按1英寸=25.4毫米换算,那么A3纸大约是11.6英寸*16.5英寸" 3380*4950
m_nDstWidth = nScaledWidth;
m_nDstHeight = nScaledHeight;
int nRet = m_dicomDp->SaveDcmToZoomBmp(nImageCloumn,nImageLine,m_nDstWidth,m_nDstHeight,_bstr_t(strBmpName),IMG_BMP);
m_dicomDp->ReleaseDicomFile();
strBmpName.AppendFormat(_T(".bmp"));
g_Log.Debug(strBmpName);
//ShellExecute(NULL,_T("print"),strBmpName,_T(""),_T(""), SW_HIDE);
//return FALSE;
CDC dcMemory;
dcMemory.CreateCompatibleDC(&printDC);
HBITMAP m_hPrintBitmap;
PBITMAPINFO pBitmapInfo1 = CreateHPBITMAPINFO(nScaledWidth, nScaledHeight, false, false) ;
CDC dcMemory1;
dcMemory1.CreateCompatibleDC(NULL/*&Viewdc*/);
BYTE* pBmpBits1 = NULL;
m_hPrintBitmap = CreateDIBSection(dcMemory1.GetSafeHdc(), pBitmapInfo1, DIB_RGB_COLORS, (void**)&pBmpBits1, NULL, NULL);
memset(pBmpBits1,0,nScaledWidth*nScaledHeight*3);
CBitmap* bkBitmap =CBitmap().FromHandle(m_hPrintBitmap);
CBitmap* pOldBitmap= dcMemory.SelectObject(bkBitmap);
HBITMAP m_hBitmap;
m_hBitmap = (HBITMAP)::LoadImage( AfxGetInstanceHandle(),
strBmpName,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION );
if (m_hBitmap == NULL)
{
DeleteObject(m_hPrintBitmap);
DeleteObject(m_hBitmap);
AfxMessageBox(_T("LoadImage失败!"));
return false;
}
CBitmap bmp;
bmp.Attach( m_hBitmap );
CDC memDC;
memDC.CreateCompatibleDC(&printDC);
memDC.SelectObject(&bmp);
BITMAP BitInfo;
bmp.GetBitmap(&BitInfo);
int nBmpWidth = BitInfo.bmWidth;
int nBmpHeight = BitInfo.bmHeight;
//SaveBmp(m_hBitmap,_T("e:\\printdir\\222.bmp"));
//printDC.StretchBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0,nBmpWidth,nBmpHeight, SRCCOPY);
//if (printDC != NULL)
//{
// printDC.SetBkMode(OPAQUE);
// printDC.SetBkColor(RGB(0,0,0));
// printDC.SetTextColor(RGB(255,255,255));
//}
dcMemory.BitBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0, SRCCOPY);
//dcMemory.SetPixel(0,0,RGB(255,0,0));
//dcMemory.SetPixel(0,1,RGB(255,0,0));
//dcMemory.Draw3dRect(0,0,500,500,RGB(0,255,0),RGB(0,255,0));
//dcMemory.TextOut(nScaledWidth/2,100,_T("医疗信息技术有限公司"
printDC.BitBlt(0,0,nScaledWidth,nScaledHeight,&dcMemory,0,0, SRCCOPY);
//printDC.StretchBlt(0,0,nScaledWidth,nScaledHeight,&memDC,0,0,nBmpWidth,nBmpHeight, SRCCOPY);
CString strDCBmpPath;
strDCBmpPath.Format(_T("%s\\DC_%s.bmp"),m_StrBmpFloder,strDateTime);
SaveBmp(m_hPrintBitmap,strDCBmpPath);
printDC.EndPage();
printDC.EndDoc();
printDC.Detach();
DeleteObject(m_hPrintBitmap);
DeleteObject(m_hBitmap);
DeleteObject(bmp);
dcMemory.DeleteDC();
memDC.DeleteDC();
printDC.DeleteDC();
g_Log.Debug(_T("执行打印完毕"));
//CoUninitialize();//释放COM
}
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
//
0 0
- Teminator 自己看别人看了没用
- 自己看别人看了没用
- 解析,自己看别人看了没用
- 自己看别人看了没用-多组调图
- 自己看,别人看了没用 私有buff解析
- 自己看别人看了没用,UNICODE下连接数据库
- 自己看别人看了没用,dicomcs相关操作
- 以后看,别人看了没用
- 自己看,别人看了没用,画图和测量基础学习
- 111.html测试测量角度 自己看别人看了没用
- 自己看别人看没用-调试断点问题
- 自己看别人看了没用,遇到的查询很慢用的几个sql,备份用来查问题
- 删除一个病人检查,别人看了没用
- 自己看别人看没用--读取bmp并刷到dc
- C# TCP 自己看,别人看了没有用
- 清醒看自己,糊涂看别人
- 清除临时文件,自己看别人看没有用
- 有道阅读,想自己看别人
- Kafka Producer
- MySQL的备份与还原
- [Android] BroadcastReceiver - 廣播接收器
- 14 面向对象 继承
- tomcat,mysql,linux服务器性能调优
- Teminator 自己看别人看了没用
- JEval使用实例
- JavaSE实战——API(上) Eclipse使用、Object、Scanner、String、StringBuffer、StringBuilder、Integer、模拟用户登录案例
- 版本控制git(三)-git分支
- PullToRefreshListView 使用 onItemLongClick 的正确打开方式
- Node.js学习开始了——事件流的控制/文件读写事件的的方法
- Apache与Nginx的优缺点比较
- 15 面向对象 抽象类 内部类 Object类
- android应用开发--------------看RadioGroup源码,写类似单选选项卡的集成控件(如底部导航,tab等等)