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. Convert Screen Rect to Printer Rect

Convert Screen Rect to Printer Rect

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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 Rect say (0, 16, 0, 154) and i want to print it out with that same rect on a printer. on the printer dc i say int nOldMapMode = dc.SetMapMode(MM_HIENGLISH); dc.DPtoLP(rect); it converts it to (0, -27, 0, 257) wich is way to small for the printer. How do i convert this rect to the same rect for a printer? Scott

    N 1 Reply Last reply
    0
    • G Gilfrog

      I have a Rect say (0, 16, 0, 154) and i want to print it out with that same rect on a printer. on the printer dc i say int nOldMapMode = dc.SetMapMode(MM_HIENGLISH); dc.DPtoLP(rect); it converts it to (0, -27, 0, 257) wich is way to small for the printer. How do i convert this rect to the same rect for a printer? Scott

      N Offline
      N Offline
      Nitron
      wrote on last edited by
      #2

      HDC hdcPrinter;
      CPrintDialog dlg(FALSE);
      // get a dc for the screen and attach it to a CDC
      CDC dcScreen;
      HDC hdcScreen = ::GetDC(NULL);
      dcScreen.Attach(hdcScreen);

      if (dlg.DoModal() == IDOK)
      {
      hdcPrinter=dlg.GetPrinterDC();

      long logicalPixelsPerInchX\_Screen = GetDeviceCaps(hdcScreen, LOGPIXELSX); 
      long logicalPixelsPerInchY\_Screen = GetDeviceCaps(hdcScreen, LOGPIXELSY); 
      
      long logicalPixelsPerInchX\_Printer = GetDeviceCaps(hdcPrinter, LOGPIXELSX);
      long logicalPixelsPerInchY\_Printer = GetDeviceCaps(hdcPrinter, LOGPIXELSY);
      

      }

      - Nitron


      "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

      G 1 Reply Last reply
      0
      • N Nitron

        HDC hdcPrinter;
        CPrintDialog dlg(FALSE);
        // get a dc for the screen and attach it to a CDC
        CDC dcScreen;
        HDC hdcScreen = ::GetDC(NULL);
        dcScreen.Attach(hdcScreen);

        if (dlg.DoModal() == IDOK)
        {
        hdcPrinter=dlg.GetPrinterDC();

        long logicalPixelsPerInchX\_Screen = GetDeviceCaps(hdcScreen, LOGPIXELSX); 
        long logicalPixelsPerInchY\_Screen = GetDeviceCaps(hdcScreen, LOGPIXELSY); 
        
        long logicalPixelsPerInchX\_Printer = GetDeviceCaps(hdcPrinter, LOGPIXELSX);
        long logicalPixelsPerInchY\_Printer = GetDeviceCaps(hdcPrinter, LOGPIXELSY);
        

        }

        - Nitron


        "Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb

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

        ok i have the pixals per inch, what do i do with them to convert the rect?

        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