Solved

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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 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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

16 Experts available now in Live!

Get 1:1 Help Now