I can not figure out the problem. How to print text with landscape orientation (vertically) without using the printer dialog? How to get the printer to remove the paper size I need, not A4, after printing is finished?

  • "without using the printer dialog" - as a class? Or not to give it to the user? If the latter, then specify the pens in the printer settings, there it is all there. - Hedgehog
  • I agree, you can use the printer dialog, but not show it to the user. - gecube

1 answer 1

Something like this:

// Получить принтер по умолчанию PRINTDLG pd; AfxGetApp()->GetPrinterDeviceDefaults(&pd); HANDLE mode = CopyHandle(pd.hDevMode); // Выбрать установки по умолчанию LPDEVMODE pMode = (LPDEVMODE) GlobalLock(mode); if (pMode->dmFields & DM_ORIENTATION) pMode->dmOrientation = DMORIENT_LANDSCAPE; if (pMode->dmFields & DM_PAPERSIZE) pMode->dmPaperSize = DMPAPER_A3; GlobalUnlock(mode); 

CopyHandle: to work with your handle. He will then have to be released (when he is no longer needed) with the help of GlobalFree.

 HANDLE CopyHandle(HANDLE handle) { HANDLE copy = NULL if (handle) { DWORD length = GlobalSize(h); if (copy = GlobalAlloc(GHND, length)) { BYTE* from = (BYTE *)GlobalLock(copy); BYTE* to = (BYTE *)GlobalLock(h); CopyMemory(from, to, length); GlobalUnlock(copy); GlobalUnlock(h); } } return copy; } 
  • This line mode = CopyHandle (pd.hDevMode) is a little not clear; what is - mode; and in MSDN CopyHandle () I can not find. - RSV