Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Printing Dialog Box

Printing Dialog Box

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How do I print a dialog box?

    J 1 Reply Last reply
    0
    • L Lost User

      How do I print a dialog box?

      J Offline
      J Offline
      Jeremy Davis
      wrote on last edited by
      #2

      Best thing to do is a screen grab. void CMachine::PrintWindow() { // show options CMyPrintDialog PrintDlg( FALSE, PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_NOSELECTION | PD_DISABLEPRINTTOFILE, this); int Response = 0; Response = PrintDlg.DoModal(); if (Response == IDOK) { // get printer dc HDC hPrinterDC =(HDC) 0; hPrinterDC = PrintDlg.m_pd.hDC; ASSERT(hPrinterDC != NULL); CDC PrinterDC; BOOL IsAttached = FALSE; IsAttached = PrinterDC.Attach(hPrinterDC); ASSERT(IsAttached); // Set landscape LPDEVMODE pDevMode = PrintDlg.GetDevMode(); pDevMode->dmFields |= DM_ORIENTATION; pDevMode->dmOrientation = DMORIENT_LANDSCAPE; PrinterDC.ResetDC(pDevMode); // attempt to set abort procedure int SetAbortProcStatus = 0; // SetAbortProcStatus = PrinterDC.SetAbortProc( &AbortProc ); // attempt to start print job DOCINFO DocInfo; DocInfo.cbSize = sizeof(DOCINFO); DocInfo.lpszOutput = NULL; DocInfo.lpszDocName = "PDMW Windows Screen Print"; int StartDocStatus = 0; StartDocStatus = PrinterDC.StartDoc(&DocInfo); // if abort procedure set and print job started if (SetAbortProcStatus >= 0 && StartDocStatus >= 0) { // start page VERIFY(PrinterDC.StartPage() > 0); // get the screen dc HDC hScreenDC =(HDC) 0; hScreenDC = ::GetDC(NULL);// CDC ASSERT(hScreenDC != NULL); CDC ScreenDC; VERIFY(ScreenDC.Attach(hScreenDC)); // create screen device dependent (dd) bitmap CRect tmp; GetWindowRect(tmp); // ClientToScreen(tmp); // tmp.top -= ::GetSystemMetrics(SM_CYCAPTION); int ScreenWidth = tmp.Width();// - ::GetSystemMetrics(SM_CXEDGE) * 4;// 0; // ScreenWidth = ScreenDC.GetDeviceCaps( HORZRES ); int ScreenHeight = tmp.Height();// + ::GetSystemMetrics(SM_CYCAPTION);// - ::GetSystemMetrics(SM_CYEDGE) * 4; //- ::GetSystemMetrics(SM_CYCAPTION);// 0; // ScreenHeight = ScreenDC.GetDeviceCaps( VERTRES ); CBitmap ScreenBitmap; VERIFY(ScreenBitmap.CreateCompatibleBitmap( &ScreenDC, ScreenWidth, ScreenHeight )); // copy image to screen dd bitmap CDC MemDC; VERIFY(MemDC.CreateCompatibleDC(&ScreenDC)); CBitmap* pOldBitmap = NULL; pOldBitmap = MemDC.SelectObject(&ScreenBitmap); ASSERT(pOldBitmap != NULL); VERIFY(MemDC.BitBlt( 0, 0, ScreenWidth, ScreenHeight, &ScreenDC,

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups