Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Twips to Pixels in .Net? 1

Status
Not open for further replies.

GEAK

Instructor
Feb 1, 2001
90
US
I've seen a thousands of articles on converting twips to pixels in VB6 but I'm working with VB.Net. I'm trying to manipulate a control embedded within a legacy control (ocx/dll). The component (and all sub-controls within it) report their coordinates in twips rather than pixels.

Checking the MSDN library hasn't proved very helpful - the only reference to twips is the TwipsToChartPart method of the MSChart control (and I'm not working with one of those).

I know that on average it's about 15 twips per pixel but it's dependent upon the display device. I'd like to determine it at runtime and get the right numbers rather than hard-coding an arbitrary number.

Suggestions?
 
The easiest way is to use the Microsoft.VisualBasic.Compatibility.VB6 library. Use the following functions:

microsoft.VisualBasic.Compatibility.VB6.TwipsToPixelsX
microsoft.VisualBasic.Compatibility.VB6.TwipsToPixelsY

 
Thanks stravis. Even after a couple years at VB.Net I wasn't able to find that on my own.

For anyone else running across this problem, you also need to add a reference to the MS VB Compatibility Runtime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top