CDC printDC;
CPrintDialog printDlg(FALSE);
DOCINFO docInfo;
if (printDlg.DoModal() == IDOK)
{
HDC hDC;
hDC = printDlg.GetPrinterDC();
if (!printDC.Attach(hDC))
return;
}
else
{
printDC.Detach();
return;
}
printDC.SetMapMode(MM_LOMETRIC);
CDC memDC;
CBitmap dispBmp, *oldBmp;
BITMAP bm;
HBITMAP hBitmap = (HBITMAP)::LoadImage(
::GetModuleHandle(NULL), // 模塊實體句柄(要加載的圖片在其他DLL中時)
"D:/Mr.Wang/My.Practice/Test10/Test10/res/Ewm.bmp", // 位圖路徑
IMAGE_BITMAP, // 位圖型別
0, // 指定圖片的寬
0, // 指定圖片的高
LR_LOADFROMFILE | LR_CREATEDIBSECTION);
dispBmp.Attach(hBitmap);
dispBmp.GetBitmap(&bm);
memDC.CreateCompatibleDC(&printDC);
oldBmp = memDC.SelectObject(&dispBmp);
memset(&docInfo, 0, sizeof(docInfo));
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = "Print Window";
if (printDC.StartDoc(&docInfo) <= 0)
{
printDC.Detach();
return;
}
printDC.StartPage();
printDC.StretchBlt(100, -100, 160, -160, &memDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
memDC.SelectObject(oldBmp);
memDC.DeleteDC();
printDC.EndPage();
printDC.EndDoc();
printDC.Detach();
直接貼代碼了。
0309補丁更新之前列印二維碼正常,更新之后列印例外只有一個小點了。 求大拿 測驗驗證幫忙解決。
uj5u.com熱心網友回復:
StretchBlt 的幫助檔案中已明確 坐標都是邏輯坐標bm.bmWidth, bm.bmHeight 是像素吧
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/267969.html
標籤:界面
