Solved

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

Posted on 1998-04-20
2
696 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now