Click to See Complete Forum and Search --> : Converting twip?


ericJA
May 16th, 1999, 01:15 AM
I know a twip is 1/20 of a point but what is a twip to a pixel? and a point
to a pixel conversion?

Thanks

Crazy D
May 16th, 1999, 05:37 AM
Check out the Screen.TwipsPerPixelX Screen.TwipsPerPixelY.

Gordito Supreme
May 19th, 1999, 07:47 PM
Why not set the Scale property on your form to pixels instead of twips.

Gordito

Lee Muller
March 30th, 2000, 05:45 PM
For VC++ programmers, take a look at: http://support.microsoft.com/support/kb/articles/Q196/8/33.ASP

Here are some snippets of code copied from above. You may also need to use MapDialogRect() or GetDialogBaseUnits().



int m_nLogX;
int m_nLogY;

// To convert grid rect from twips to DC units you need
// pixels per inch.
CDC* pDC = GetDC();
m_nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
m_nLogY = pDC->GetDeviceCaps(LOGPIXELSY);
ReleaseDC(pDC);

// Create invisible edit control.
m_edit.Create(WS_CHILD|ES_MULTILINE|ES_WANTRETURN,
CRect(0,0,0,0), this, GetDlgCtrlID());

// Adjust for border height and convert from twips to screen
// units.
m_edit.MoveWindow(((GetCellLeft() - m_lBorderWidth) *
m_nLogX)/1440,
((GetCellTop() - m_lBorderHeight) * m_nLogY)/1440,
(GetCellWidth()* m_nLogX)/1440,
(GetCellHeight()* m_nLogY)/1440, FALSE);
m_edit.ShowWindow(SW_SHOW);
m_edit.SetFocus();