Solved

Equivalence between twips and inches or pixels

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

729 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