Paul E Collins wrote:
perspolis wrote:
I have some points in twips measurement.how can
I convert them to pixel measurement ?
A twip is 1/1440 of an inch, so it depends on the resolution of the
screen being used and will vary between computers. You need to know
the screen size in pixels (easy to discover) and in inches (harder or
impossible at run-time) to do this conversion. It will probably be
easier for you to redesign the system from scratch to use pixels.
This is the correct advice - convert to using pixels, which is the .NET
way of doing things.
However, for those that are interested, it is possible to use Reflector
to examine the Microsoft.VisualBasic.Compatibility dll, in which is
contained translations of the VB6 methods Screen.TwipsPerPixelX and
Screen.TwipsPerPixelY (you can guess what they do). This is the direct
output from Reflector; interested parties will not find it hard to
pursue undefined references. As Paul E Collins suggests, it is indeed
'hard' to do at runtime:
private static void SetUpTwipsPerPixel(bool Force /* = false */)
{
if (!Support.m_IsTwipsPerPixelSetUp || Force)
{
Support.m_TwipsPerPixelX = 0;
Support.m_TwipsPerPixelY = 0;
try
{
IntPtr ptr1 =
NativeMethods.GetDC(NativeMethods.NullIntPtr);
if (!ptr1.Equals(NativeMethods.NullIntPtr))
{
Support.m_TwipsPerPixelX = 1440 / ((double)
NativeMethods.GetDeviceCaps(ptr1, 0x58));
Support.m_TwipsPerPixelY = 1440 / ((double)
NativeMethods.GetDeviceCaps(ptr1, 90));
NativeMethods.ReleaseDC(NativeMethods.NullIntPtr, ptr1);
}
}
catch (Exception exception1)
{
ProjectData.SetProjectError(exception1);
ProjectData.ClearProjectError();
}
Support.m_IsTwipsPerPixelSetUp = true;
if ((Support.m_TwipsPerPixelX == 0) ||
(Support.m_TwipsPerPixelY == 0))
{
Support.m_TwipsPerPixelX = 15;
Support.m_TwipsPerPixelY = 15;
VB6Errors.RaiseError(7,
Resources.GetResourceString("Misc_SetUpTwipsPerPix el"));
}
}
}
--
Larry Lard
Replies to group please