Solved

Equivalence between twips and inches or pixels

Posted on 2000-05-13
3
785 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

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

10 Experts available now in Live!

Get 1:1 Help Now