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. CEdit question

CEdit question

Scheduled Pinned Locked Moved C / C++ / MFC
questionai-modelshelp
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.
  • B Offline
    B Offline
    Bert Tuyt
    wrote on last edited by
    #1

    I have modified the CEdit class for my own purpose. I have added a function which calculates the lineheight in a multiline edit (see next code) int CDebugEdit::GetLineHeight() { int iLineHeight, itmHeight, itmExternalLeading ; CDC* pDC ; TEXTMETRIC tm ; pDC = GetDC() ; pDC->GetTextMetrics(&tm) ; itmHeight = tm.tmHeight ; itmExternalLeading = tm.tmExternalLeading ; iLineHeight = itmHeight + itmExternalLeading ; return ( iLineHeight ) ; } However when i change the Font size in the edit (and I see the result in the edit window) I get always the same value for iLineHeight, it appears that although the Font size is changed the tm structure always returns with the same values. Can someone help me ? Bert :confused:

    R 1 Reply Last reply
    0
    • B Bert Tuyt

      I have modified the CEdit class for my own purpose. I have added a function which calculates the lineheight in a multiline edit (see next code) int CDebugEdit::GetLineHeight() { int iLineHeight, itmHeight, itmExternalLeading ; CDC* pDC ; TEXTMETRIC tm ; pDC = GetDC() ; pDC->GetTextMetrics(&tm) ; itmHeight = tm.tmHeight ; itmExternalLeading = tm.tmExternalLeading ; iLineHeight = itmHeight + itmExternalLeading ; return ( iLineHeight ) ; } However when i change the Font size in the edit (and I see the result in the edit window) I get always the same value for iLineHeight, it appears that although the Font size is changed the tm structure always returns with the same values. Can someone help me ? Bert :confused:

      R Offline
      R Offline
      Rohit Sinha
      wrote on last edited by
      #2

      um, i can't say this for sure, but i think that the font selected in the dc and the font set in the edit box need not be the same. i remember facing something similar long time back when i changed the font selected in the dc but had the edit box showing the text in a different font. i am not sure why this happens, or even whether this is happening in your case, but there you are. i suggest using the CWnd::GetFont() funntion and then CFont::GetLogFont() function on the returned CFont pointer from CEdit::GetFont() funtion. you can then use the LOGFONT structure to get the data you need. not sure if this is the solution though. ;P

      Regards,

      Rohit Sinha

      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