?
Solved

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

Posted on 1998-04-20
2
Medium Priority
?
735 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 400 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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

765 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