Function GetTwipsPerPixel()
Dim objOneInchInput
Set objOneInchInput = document.createElement("input")
With objOneInchInput
.id = "txtTwip"
.type = "text"
.style.visibility = "hidden"
.style.width = "1in"
End With
document.body.appendChild objOneInchInput
GetTwipsPerPixel = 1440 / objOneInchInput.offsetWidth
document.body.removeChild objOneInchInput
Set objOneInchInput = Nothing
End Sub
This code simply creates a dynamic html input text box, makes it
hidden, sets it's style width to 1 inch, appends it to the body, and
then, since there are 1440 twips per inch, divides the pixel width of
the input box into 1440. If you are using large fonts, this returns 12
twips per pixel, and if you are using small fonts on your machine, it
returns 15 twips per pixel.
Hope this helps some folks out there. . .
Jonathan
I personally do not see the need, but this is one of the more
insteresting routines I have seen. in here in quite some time. Nice
addition, Jonathan.
For those who are not familiar, twips are the unit of measure in
Visual Basic. You will see them if you get into desktop development.
Gregory A. Beamer
MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge (3Q 2001)
****************************************************
Think Outside the Box!
****************************************************
Marc
Thanks for all the great comments. I originally needed a twip count on
my page for an activeX control. Hopefully in later script releases
Microsoft might expose a built in method or property for this, but in
the meantime, this little function works great.
Thanks again guys for the compliments!
Jonathan