Solved

How to get char height from yHeight in CHARFORMAT (using RichEdit control)

Posted on 1998-04-20
2
717 Views
Last Modified: 2013-12-03
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?

Thanks,

Nick Woods
0
Comment
Question by:woodsnick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
RONSLOW earned 100 total points
ID: 1298831
CHARFORMAT returns height in TWIPS 1/1440th in
You want size in logical units (probably pixels)
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1298832
To convert from twips to logical units

int logpixelsy = pDC->GetDeviceCaps(LOGPIXELSY);
int pixels = MulDiv(cf.yHeight,logpixelsy,1440);

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question