Tools Links Login

Pixels to Twips

This converts pixels to twips

Original Author: unknown

Inputs

# of Pixels or twips

Assumptions

This converts pixels to twips, if you get the rect of a window it's in pixels, to make your form that size you need to convert the pixels to twips.
As someone pointed out in one of my other submisions, it might be a little faster to take away the function and just use the insides where needed but i find the function saves some typing and makes the code easier to read.

Returns

# of pixels or twips... see code

Code

Function PixelsToTwips_height(pxls)
PixelsToTwips_height = pxls * screen.TwipsPerPixelY
end function
Function PixelsToTwips_width(pxls)
PixelsToTwips_width = pxls * screen.TwipsPerPixelX
end function
'This next part reverses the las although you should
'be able to use basic math
Function TwipsToPixels_height(pxls)
PixelsToTwips_height = pxls screen.TwipsPerPixelY
end function
Function TwipsToPixels_width(pxls)
PixelsToTwips_width = pxls screen.TwipsPerPixelX
end function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 97 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.