You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.7 KiB
C++

#include "StdAfx.h"
#include "PrintView.h"
#include "GlobalFunction.h"
#include "FileMgr.h"
CPrintViewMgr::CPrintViewMgr(void)
{
}
CPrintViewMgr::~CPrintViewMgr(void)
{
}
CString CPrintViewMgr::GetPrintViewFullFilePath()
{
CString FullFilePath;
CString FileName = "\\View.bmp";
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
CFileMgr FileMgr;
FileMgr.GetFullFilePath(FullFilePath,FileName);
return FullFilePath;
}
//<2F><>ӡview <20><><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>һ<EFBFBD><D2BB>bmp ͼƬ
void CPrintViewMgr::PrintViewToBmp(HDC hDC,RECT rect)
{
CString FullFilePath = GetPrintViewFullFilePath();
PrintViewToBmpExt(FullFilePath,hDC,rect);
}
void CPrintViewMgr::PrintViewToBmpExt(CString Path,HDC hDC,RECT rect)
{
HDC hDCMem = ::CreateCompatibleDC(hDC);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DC
HBITMAP hBitMap = ::CreateCompatibleBitmap(hDC, rect.right, rect.bottom);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λͼ
HBITMAP hOldMap = (HBITMAP)::SelectObject(hDCMem, hBitMap);//<2F><>λͼѡ<CDBC><D1A1>DC<44><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B7B5>ֵ
::BitBlt(hDCMem, 0, 0, rect.right, rect.bottom, hDC, 0, 0, SRCCOPY);//<2F><><EFBFBD><EFBFBD>ĻDC<44><43>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>ڴ<EFBFBD>DC<44><43>
CImage image;
image.Attach(hBitMap);
image.Save(Path);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>׺Ϊ.bmp<6D><70><EFBFBD>򱣴<EFBFBD>ΪΪbmp<6D><70>ʽ
image.Detach();
::SelectObject(hDCMem, hOldMap);//ѡ<><D1A1><EFBFBD>ϴεķ<CEB5><C4B7><EFBFBD>ֵ
//<2F>ͷ<EFBFBD>
::DeleteObject(hBitMap);
::DeleteDC(hDCMem);
//::DeleteDC(hDC);
}
//<2F><><EFBFBD><EFBFBD>Ϊbmp <20>ļ<EFBFBD>
void CPrintViewMgr::SaveToBmpFile(HDC hDC,RECT rect)
{
TCHAR szFilters[]=("BMP <20>ļ<EFBFBD>(*.bmp)|*.bmp");
CFileDialog dlg(FALSE,("bmp"),("BmpFile"),OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters);
if(dlg.DoModal()==IDOK)
{
PrintViewToBmpExt(dlg.GetPathName(),hDC,rect);
}
}