|
|||||||
| TX Text Control ActiveX Please use this forum for TX Text Control ActiveX support only. If you need support for a different product, please use the appropriate forum. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Most of you probably already know how to do this, but I just figured it out. If you're using MFC, the following C++ code can be used to convert between TWIPS and pixels.
Code:
(afxwin.h is the required header)
const int TWIPS_PER_INCH = 1440;
[...]
inline int TwipsToPixels(int twips) { return (twips * m_devicePixelsPerInch / TWIPS_PER_INCH); }
inline int PixelsToTwips(int pixels) { return (pixels * TWIPS_PER_INCH / m_devicePixelsPerInch); }
[...]
int m_devicePixelsPerInch;
[...]
// this code goes in the constructor
CClientDC dc(this); // 'this' is any CWnd-derived object
m_devicePixelsPerInch = dc.GetDeviceCaps( LOGPIXELSY );
Last edited by Gunnar Giffey; December 4, 2009 at 16:00:10. Reason: Please use [CODE][/CODE] tags when posting source code. Thanks! |
|
#2
|
||||
|
||||
|
Re: Converting between TWIPS and pixels (C++/MFC)
but as your using fixed measurements you could just use constants like:
TwipsPerInch = 1440; {Same as minutes per day} TwipsPerPixel = 15; TwipsPerMil = 56.7; |
![]() |
| Bookmarks |
| Tags |
| c++ , convert , mfc , pixels , twips |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Autosize & Twips --> Pixel question | xyzabc1010 | TX Text Control .NET | 1 | November 19, 2008 09:42:23 |