Solved

Equivalence between twips and inches or pixels

Posted on 2000-05-13
3
791 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
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
vbk_bgm earned 70 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Importing Special Characters in Dynamics GP Through Integration Manager 3 75
withoutTen challenge 14 120
Fibonacci challenge 11 121
Path of Workbook 3 77
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 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.

776 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