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. Get String size Height and Width

Get String size Height and Width

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++comgraphics
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.
  • K Offline
    K Offline
    Khatri Mitesh
    wrote on last edited by
    #1

    Hi, I am new to Win-32 C++. and i want to get the string size (Height and Width) of a string Like ( In VB.Net )

    Dim strSize As SizeF
    strSize = e.Graphics.MeasureString("Mitesh Khatri", New Font("Sans Serif", 9, FontStyle.Bold))

    How i get same thing in Win-32 C++. Please suggest. Thanks

    ~Khatri Mitesh khatrimitesh@hotmail.com Bikaner (Rajasthan) INDIA

    C L J 3 Replies Last reply
    0
    • K Khatri Mitesh

      Hi, I am new to Win-32 C++. and i want to get the string size (Height and Width) of a string Like ( In VB.Net )

      Dim strSize As SizeF
      strSize = e.Graphics.MeasureString("Mitesh Khatri", New Font("Sans Serif", 9, FontStyle.Bold))

      How i get same thing in Win-32 C++. Please suggest. Thanks

      ~Khatri Mitesh khatrimitesh@hotmail.com Bikaner (Rajasthan) INDIA

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

      How are you displaying the string ? Using CDC::TextOut ? If yes, then you can use CDC::GetTextExtent[^]

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      • K Khatri Mitesh

        Hi, I am new to Win-32 C++. and i want to get the string size (Height and Width) of a string Like ( In VB.Net )

        Dim strSize As SizeF
        strSize = e.Graphics.MeasureString("Mitesh Khatri", New Font("Sans Serif", 9, FontStyle.Bold))

        How i get same thing in Win-32 C++. Please suggest. Thanks

        ~Khatri Mitesh khatrimitesh@hotmail.com Bikaner (Rajasthan) INDIA

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        ~Khatri Mitesh~ wrote:

        I am new to Win-32 C++

        I see, then you want to become familiar with this[^]

        1 Reply Last reply
        0
        • K Khatri Mitesh

          Hi, I am new to Win-32 C++. and i want to get the string size (Height and Width) of a string Like ( In VB.Net )

          Dim strSize As SizeF
          strSize = e.Graphics.MeasureString("Mitesh Khatri", New Font("Sans Serif", 9, FontStyle.Bold))

          How i get same thing in Win-32 C++. Please suggest. Thanks

          ~Khatri Mitesh khatrimitesh@hotmail.com Bikaner (Rajasthan) INDIA

          J Offline
          J Offline
          Joe Woodbury
          wrote on last edited by
          #4

          To further clarify what Cedric said, you first get a device context, select the font you be using into it and then all GetTextExtent(). (This may sound obvious to experienced developers, but the failure to select the font is a common mistake.)

          Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

          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