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