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 a custom control

Printing a custom control

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphics
4 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.
  • G Offline
    G Offline
    Gilfrog
    wrote on last edited by
    #1

    I have a custom control that i do all the drawing on. If i want to print the control can i just replace the DC with a DC i get from CPrintDialog? This works but it prints reeeally small. How can i get it to print so it is the same size as on the screen? Scott

    C 1 Reply Last reply
    0
    • G Gilfrog

      I have a custom control that i do all the drawing on. If i want to print the control can i just replace the DC with a DC i get from CPrintDialog? This works but it prints reeeally small. How can i get it to print so it is the same size as on the screen? Scott

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      your screen is probably at 96 DPI, but the printer is likely 300 or 600 DPI. so, it's drawing with the same number of dots, but the dots are much smaller. what you need to do is to set the printer DPI (in effect) to the same as your screen DPI. you can do this by adjust the DC's extents (see SetViewportExtent and SetWindowExtent and maybe SetMappingMode). this might work for you: pDC->SetMapMode(MM_ISOTROPIC); pDC->SetWindowExt(desiredDPI); pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); -c


      When history comes, it always takes you by surprise.

      Bobber!

      G 1 Reply Last reply
      0
      • C Chris Losinger

        your screen is probably at 96 DPI, but the printer is likely 300 or 600 DPI. so, it's drawing with the same number of dots, but the dots are much smaller. what you need to do is to set the printer DPI (in effect) to the same as your screen DPI. you can do this by adjust the DC's extents (see SetViewportExtent and SetWindowExtent and maybe SetMappingMode). this might work for you: pDC->SetMapMode(MM_ISOTROPIC); pDC->SetWindowExt(desiredDPI); pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY)); -c


        When history comes, it always takes you by surprise.

        Bobber!

        G Offline
        G Offline
        Gilfrog
        wrote on last edited by
        #3

        What should the desiredDPI be? I tried 96 and it seems to work pretty good but it prints everything a little smaller than it should be. I can play around with desiredDPI and get it to print almost exactly like it is on the screen but there's got to be a way to figure what this value should be? Scott

        C 1 Reply Last reply
        0
        • G Gilfrog

          What should the desiredDPI be? I tried 96 and it seems to work pretty good but it prints everything a little smaller than it should be. I can play around with desiredDPI and get it to print almost exactly like it is on the screen but there's got to be a way to figure what this value should be? Scott

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          try 72


          When history comes, it always takes you by surprise.

          Bobber!

          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