How to get char height from yHeight in CHARFORMAT (using RichEdit control)
Posted on 1998-04-20
I'm using a RichEdit control and want to figure out the number of lines in the
current window so I can automatically scroll it. When I use MyRichEditCtrl.GetDC()->GetTextMetrics(&metric), tmHeight, etc. do not
provide me with the right numbers. They are a little too small, even with externalLeading and so when my window gets big of course, the number of lines is off.
The RichEdit control however can also retrieve a filled in CHARFORMAT structure for the control. I wanted to use the tmHeight as the pixel height so I can divide the ClientRect by the value to obtain the number of lines but for a normal size font I get a value of 180 which is well more than the pixel height of the font.
How then can I get the number of possible visible lines in a RichEdit control, i.e. how can I use the yHeight value to my advantage? Do I need to divide by some sort of SystemMetric to find the value?