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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GDI Portability

GDI Portability

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphics
2 Posts 1 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
    Larry J Siddens
    wrote on last edited by
    #1

    Alright you guru's. I have a question for ya. I have a test application that at first I set all the GDI objects (boxes, Rich Edit control, and lines) using the MM_TEXT (display locations). I found out what a logical inch was (Using MM_TWIPS at 1440x1440) and converted that to display for the current display and printer. On my main system the conversion from LPtoDP returned 102x108 and for the printer 1201x1204. When I copied the application to a different OS (using VMWARE), with the resolution set to 1024x768 and doing the same thing, it returned either 81x81 (or 96x96) and the printer varried by 1 or 2 (probably due to rounding). When I would print using the display locations, I wanted the boxes to be 1inch x 3inch and 1inch x 7 inches. The print outs as I expected were not 1x3 or 1x7 or even close. Using the Logical units they were pretty close! Next I tried switching all the values to TWIPS and then converting the TWIPS to display units to create the controls. On my main system, it looked darn good. On the VMWARE Os, the output looked different. What I need is several fold.

    1. Am I correct in saving the logical (TWIPS) values and using LPtoDP to convert to display units to create the controls?
    2. Is my assmption correct in saying that 1440x1440 converting to LPtoDP gives the correct DPI for one inch the way the display is configured?
    3. What are the traps that I maybe falling into and how do I avoid them. Device independent drawing.

    Thanks Larry J. Siddens Cornerstone Communications TAME THE DOCUMENT MONSTER www.unifier.biz

    L 1 Reply Last reply
    0
    • L Larry J Siddens

      Alright you guru's. I have a question for ya. I have a test application that at first I set all the GDI objects (boxes, Rich Edit control, and lines) using the MM_TEXT (display locations). I found out what a logical inch was (Using MM_TWIPS at 1440x1440) and converted that to display for the current display and printer. On my main system the conversion from LPtoDP returned 102x108 and for the printer 1201x1204. When I copied the application to a different OS (using VMWARE), with the resolution set to 1024x768 and doing the same thing, it returned either 81x81 (or 96x96) and the printer varried by 1 or 2 (probably due to rounding). When I would print using the display locations, I wanted the boxes to be 1inch x 3inch and 1inch x 7 inches. The print outs as I expected were not 1x3 or 1x7 or even close. Using the Logical units they were pretty close! Next I tried switching all the values to TWIPS and then converting the TWIPS to display units to create the controls. On my main system, it looked darn good. On the VMWARE Os, the output looked different. What I need is several fold.

      1. Am I correct in saving the logical (TWIPS) values and using LPtoDP to convert to display units to create the controls?
      2. Is my assmption correct in saying that 1440x1440 converting to LPtoDP gives the correct DPI for one inch the way the display is configured?
      3. What are the traps that I maybe falling into and how do I avoid them. Device independent drawing.

      Thanks Larry J. Siddens Cornerstone Communications TAME THE DOCUMENT MONSTER www.unifier.biz

      L Offline
      L Offline
      Larry J Siddens
      wrote on last edited by
      #2

      HUMMM, I maybe assuming something that is not correct! The code to calculate the LPtoDP is as follows: Lx = Logical x direction WOx = Window Org x direction VOx = Viewport Org x direction WEx = Window Extent x direction VEx = Viewport Extent x direction Dx = Device Unit x direction Dx = ( Lx - WOx ) * VEx / WEx + VOx So, with this knowledge in a 1280x1024 resolution screen the values are as follows: Dx = ( 1440 - 0 ) * 1280 / 18142 + 0 Dx = 101.598501 and rounded up to 102. When this same calculation is done on a 1024x768 screen the value rounded come out to be 81. So, the question is how do I get the text (rich edit... starting to hate these things!) that was created in a 1024x768 res screen like it did when it was created in a 1280x1024? Do I come up with some puzzles or what? Thanks if you can answer. I really guess I don't quite understand! Larry J. Siddens Cornerstone Communications TAME THE DOCUMENT MONSTER www.unifier.biz

      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