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. How to display vertical text using DrawText

How to display vertical text using DrawText

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
2 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.
  • M Offline
    M Offline
    Mary Chennai
    wrote on last edited by
    #1

    Hi, CDC* pDc = GetDC(); CSize cSize = pDc->GetTextExtent( "1", 1 ); CRect cRect ( 0, iPadding, cSize.cx, cSize.cy ); pDc->DrawText( "1", 1, &cRect , DT_CENTER|DT_VCENTER|DT_NOCLIP ); The above code displays the text "1" horizontally in cRect . To display the text vertically, i did as follows: CFont newFont; newFont.CreateFont(24, 0, 900, 900, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); CFont* pFont = pDC->SelectObject(&newFont); pDC->DrawText("1", 1, &cRect, DT_CENTER|DT_VCENTER|DT_NOCLIP); pDC->SelectObject(pFont); newFont.DeleteObject(); But in this case, I couldnt get any text displayed. Please can someone help me to get the text displayed vertically. How should cRect be manipulated to draw the text vertically?

    Mary

    D 1 Reply Last reply
    0
    • M Mary Chennai

      Hi, CDC* pDc = GetDC(); CSize cSize = pDc->GetTextExtent( "1", 1 ); CRect cRect ( 0, iPadding, cSize.cx, cSize.cy ); pDc->DrawText( "1", 1, &cRect , DT_CENTER|DT_VCENTER|DT_NOCLIP ); The above code displays the text "1" horizontally in cRect . To display the text vertically, i did as follows: CFont newFont; newFont.CreateFont(24, 0, 900, 900, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); CFont* pFont = pDC->SelectObject(&newFont); pDC->DrawText("1", 1, &cRect, DT_CENTER|DT_VCENTER|DT_NOCLIP); pDC->SelectObject(pFont); newFont.DeleteObject(); But in this case, I couldnt get any text displayed. Please can someone help me to get the text displayed vertically. How should cRect be manipulated to draw the text vertically?

      Mary

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Did you see here or here? Have you tried playing with different CRect values? You've probably just made the drawing area too restrictive.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Man who follows car will be exhausted." - Confucius

      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