?
Solved

Equivalence between twips and inches or pixels

Posted on 2000-05-13
3
Medium Priority
?
797 Views
Last Modified: 2013-11-20
Hi all..

I have added an ActiveX control to my application.. specifically it is a FlexGrid control. I need to know the height of the row so that I will be able to define the number of rows at run time. The problem is that the FlexGrid RowHeight property returns a value measured in twips, so that I need to convert it into pixels. That way I could use GetClientRect to know how many rows the control need to have when application is initialized.

I use Visual C++ 6.0.

Any advice? suggestion? help?
Thanks a lot in advance

Demarcy
0
Comment
Question by:demarcy
[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
3 Comments
 
LVL 2

Accepted Solution

by:
vbk_bgm earned 280 total points
ID: 2807943
Hi,
1440 twips make an inch(=72 points).

To make conversion from pixels to twips,
CClientDC dc(this);
int pixels_per_inchX = dc.GetDeviceCaps(LOGPIXELSX);
int pixels_per_inchY = dc.GetDeviceCaps(LOGPIXELSY);
CRect rect;
GetClientRect(rect);
int client_width_in_twips = rect.Width()*1440/pixels_per_inchX;
int client_height_in_twips = rect.Height()*1440/pixels_per_inchY;

Hope this helps!
0
 

Author Comment

by:demarcy
ID: 2808588
Thanks for your comment...

I saw you used CClientDC... I have used CDC* pDC = GetDC() instead and it worked.. is it right? or should I use CClientDC in that case?

Demarcy
0
 
LVL 2

Expert Comment

by:vbk_bgm
ID: 2809712
You can use either CClientDC or GetDC. If you use GetDC make sure to release the DC using ReleaseDC.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 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