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. Device context and dimensions

Device context and dimensions

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicshelptutorial
1 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.
  • A Offline
    A Offline
    Argonia
    wrote on last edited by
    #1

    Hello, I came across something i don't understand one little bit, and i hope you can help me understand it. The code is in the function OnDraw with parameter CDC* pDC and i have the following code

    rectPreviewClient.SetRect(0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
    ...
    CDC dc;
    dc.Attach(pDC->GetSafeHdc());

    And the CRect rectPreviewClientis given to a function which draws some stuff. The map mode isn't changed and it remains MM_ANISOTROPIC even until the drawing of the elements. The thing i don't understand is how come i can print stuff for example

    dc.TextOut(0, rectPreviewClient.bottom - tm.tmHeight,....)
    //tm is from type TEXTMETRIC taken with GetTextMetrics() from dc

    when its clear the both CDC members have different dimensions. The dpi's are different pDC have 600 dpi and dc has 96. If i use GetDeviceCaps(HORZRES) and GetDeviceCaps(VERTRES)on dc i get smaller numbers and yet i can print stuff with a lot higher coordinates. Note: The dc is used for PrintPreview. Currently i am trying to change the font size and i need to change the map mode to MM_TEXT but when i call TextOut with the coordinates normally used the text is drown outside the CDC. If the MM_TEXT is removed the text is shown but too small Edit: I fixed the Font size without changing the map mode with CreatePointFont and height of the Font size but the question remains How can i use coordinates from one CDC to another with different dpi and dimensions. Any help will be appreciated. Thank you in advance.

    Microsoft ... the only place where VARIANT_TRUE != true

    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