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. Help needed for calculating font height.!!

Help needed for calculating font height.!!

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 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.
  • R Offline
    R Offline
    Rajesh_Parameswaran
    wrote on last edited by
    #1

    Hi All, I'm trying to customize CEdit control to create dynamically growing and shrinking edit control by height. I'm stucked where I need to calculate the new height of the edit control, when the number of text exceeds the current limit. I 'm having the parameter which tells me the number of lines. I succeeded for the case of small fonts. I used the following formula: nHeight = 13 * m_LineCount + 6; This works fine.!! But I would like to generalize this..! So Can Anyone help me to calculate the height for any font. even if the font is set small / large / custom. It would be helpful for me if someone can help me to sort this out.!! :) Thanks & Regards! Rajesh

    R 1 Reply Last reply
    0
    • R Rajesh_Parameswaran

      Hi All, I'm trying to customize CEdit control to create dynamically growing and shrinking edit control by height. I'm stucked where I need to calculate the new height of the edit control, when the number of text exceeds the current limit. I 'm having the parameter which tells me the number of lines. I succeeded for the case of small fonts. I used the following formula: nHeight = 13 * m_LineCount + 6; This works fine.!! But I would like to generalize this..! So Can Anyone help me to calculate the height for any font. even if the font is set small / large / custom. It would be helpful for me if someone can help me to sort this out.!! :) Thanks & Regards! Rajesh

      R Offline
      R Offline
      Ritu Kwatra
      wrote on last edited by
      #2

      How about using CFont *font = GetFont(); LOGFONT lf; font->GetLogFont(&lf); nHeight = lf.lfHeight * m_LineCount +6; I think it will work. Ritu Kwatra

      R 1 Reply Last reply
      0
      • R Ritu Kwatra

        How about using CFont *font = GetFont(); LOGFONT lf; font->GetLogFont(&lf); nHeight = lf.lfHeight * m_LineCount +6; I think it will work. Ritu Kwatra

        R Offline
        R Offline
        Rajesh_Parameswaran
        wrote on last edited by
        #3

        Hi Ritu, Thanks for the response. But it seems to be not working throughout. This works fine for first few lines, after that for some case, the number of lines get incremented by double instead of single. Expecting more ideas.. :) Thanks and regards!! Rajesh

        R 1 Reply Last reply
        0
        • R Rajesh_Parameswaran

          Hi Ritu, Thanks for the response. But it seems to be not working throughout. This works fine for first few lines, after that for some case, the number of lines get incremented by double instead of single. Expecting more ideas.. :) Thanks and regards!! Rajesh

          R Offline
          R Offline
          Ritu Kwatra
          wrote on last edited by
          #4

          Hi Rajesh, Are you sure that your linecount parameter is giving you correct value ? If possible, mail me the piece of code. Ritu Kwatra

          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