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. Size of paper in MFC print preview?

Size of paper in MFC print preview?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++graphics
6 Posts 4 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.
  • D Offline
    D Offline
    Daniel Strigl
    wrote on last edited by
    #1

    I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!

    C R 2 Replies Last reply
    0
    • D Daniel Strigl

      I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!

      C Offline
      C Offline
      csc
      wrote on last edited by
      #2

      Do it like that : CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) ); for details have a look at the msdn : int CDC::GetDeviceCaps( int nIndex ) - HORZSIZE Width of the physical display (in millimeters). - VERTSIZE Height of the physical display (in millimeters). - HORZRES Width of the display (in pixels). - VERTRES Height of the display (in raster lines).

      D 1 Reply Last reply
      0
      • C csc

        Do it like that : CRect crPrintPaperRect = CRect( 0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES) ); for details have a look at the msdn : int CDC::GetDeviceCaps( int nIndex ) - HORZSIZE Width of the physical display (in millimeters). - VERTSIZE Height of the physical display (in millimeters). - HORZRES Width of the display (in pixels). - VERTRES Height of the display (in raster lines).

        D Offline
        D Offline
        Daniel Strigl
        wrote on last edited by
        #3

        Thanks! It works! :) I use it like in the following code:

        if (pDC->IsPrinting())
        {
        rtClient = CRect(0, 0,
        pDC->GetDeviceCaps(HORZRES),
        pDC->GetDeviceCaps(VERTRES));
        }
        else
        {
        GetClientRect(&rtClient);
        }

        Daniel ;) --------------------------- Never change a running system!

        B 1 Reply Last reply
        0
        • D Daniel Strigl

          Thanks! It works! :) I use it like in the following code:

          if (pDC->IsPrinting())
          {
          rtClient = CRect(0, 0,
          pDC->GetDeviceCaps(HORZRES),
          pDC->GetDeviceCaps(VERTRES));
          }
          else
          {
          GetClientRect(&rtClient);
          }

          Daniel ;) --------------------------- Never change a running system!

          B Offline
          B Offline
          basementman
          wrote on last edited by
          #4

          If you want to be really accurate, you should call DeviceCapabilities() to open the device that you will be printing to. One of the parameters to OpenPrinter is a good old DEVMODE struct (lots of good info). Also, you should look at the PHYSICALOFFSETX and PHYSICALOFFSETY to determine the non-printable areas of the physical page (YOUR MIN MARGIN). On laser printers, this is usually 0.25 inches around.

          1 Reply Last reply
          0
          • D Daniel Strigl

            I want to use the print / print preview of the MFC framework. I want to stretch my dawing on the whole size of the paper. So, here my question: How can I get the size (in pixel) of the whole paper, so that I can stretch my drawing so that it uses the whole paper. Daniel ;) --------------------------- Never change a running system!

            R Offline
            R Offline
            Roger Allen
            wrote on last edited by
            #5

            In print/preview in your OnPrint() procedure which generates the output, the paper size can always be found in the CPrintInfo::m_rectDraw object. So you should be able to read this rect value and StretchBlt the pic to this size. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

            D 1 Reply Last reply
            0
            • R Roger Allen

              In print/preview in your OnPrint() procedure which generates the output, the paper size can always be found in the CPrintInfo::m_rectDraw object. So you should be able to read this rect value and StretchBlt the pic to this size. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003

              D Offline
              D Offline
              Daniel Strigl
              wrote on last edited by
              #6

              Thanks Roger! It works! Daniel ;) --------------------------- Never change a running system!

              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