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. Determine bounding rect of a string [modified]

Determine bounding rect of a string [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 4 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
    AnTri
    wrote on last edited by
    #1

    Hey, I've a string including multiple lines. Now I want to use the DrawText DT_CALC feature to calc the height of the bounding rectangle, but leave the right side as it is. The returning rect has always a extended right side. How can I solve this problem? Thank you... CRect reRect(0,0,150,0); CString szText("Hallo\ndies ist ein Test\nHello\nthis is a test"); pDC->DrawText(szText,&reRect, DT_CALCRECT); -- modified at 9:12 Wednesday 28th June, 2006

    C V M 3 Replies Last reply
    0
    • A AnTri

      Hey, I've a string including multiple lines. Now I want to use the DrawText DT_CALC feature to calc the height of the bounding rectangle, but leave the right side as it is. The returning rect has always a extended right side. How can I solve this problem? Thank you... CRect reRect(0,0,150,0); CString szText("Hallo\ndies ist ein Test\nHello\nthis is a test"); pDC->DrawText(szText,&reRect, DT_CALCRECT); -- modified at 9:12 Wednesday 28th June, 2006

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      I don't what you are trying to do but does GetTextExtent[^] help ?


      Cédric Moonen Software developer
      Charting control

      1 Reply Last reply
      0
      • A AnTri

        Hey, I've a string including multiple lines. Now I want to use the DrawText DT_CALC feature to calc the height of the bounding rectangle, but leave the right side as it is. The returning rect has always a extended right side. How can I solve this problem? Thank you... CRect reRect(0,0,150,0); CString szText("Hallo\ndies ist ein Test\nHello\nthis is a test"); pDC->DrawText(szText,&reRect, DT_CALCRECT); -- modified at 9:12 Wednesday 28th June, 2006

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #3

        Maybe you should include DT_WORDBREAK flags?

        pDC->DrawText(szText, reRect, DT_CALCRECT | DT_WORDBREAK);
        
        1 Reply Last reply
        0
        • A AnTri

          Hey, I've a string including multiple lines. Now I want to use the DrawText DT_CALC feature to calc the height of the bounding rectangle, but leave the right side as it is. The returning rect has always a extended right side. How can I solve this problem? Thank you... CRect reRect(0,0,150,0); CString szText("Hallo\ndies ist ein Test\nHello\nthis is a test"); pDC->DrawText(szText,&reRect, DT_CALCRECT); -- modified at 9:12 Wednesday 28th June, 2006

          M Offline
          M Offline
          Muhammad Azam
          wrote on last edited by
          #4

          try using \r\n instead of \n only in szText

          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