Solved

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

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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