![]() |
Click here to advertise with us
|
|
|||||||
| Windows Forms Discussion related to Winforms application development |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi everybody!
Is there any way so that i can set the measurement unit of a form from Pixels to Twips? Regards Thanks |
|
||||
|
No, it's not. You'll have to perform the conversion yourself. Here's how it's done when upgrading VB6 code to VB.NET:
Code:
Private Shared Sub SetUpTwipsPerPixel(ByVal Optional Force As Boolean = False)
If (Not Support.m_IsTwipsPerPixelSetUp OrElse Force) Then
Support.m_TwipsPerPixelX = 0
Support.m_TwipsPerPixelY = 0
Try
Dim dC As IntPtr = NativeMethods.GetDC(NativeMethods.NullIntPtr)
If Not dC.Equals(NativeMethods.NullIntPtr) Then
Support.m_TwipsPerPixelX = (1440 / CDbl(NativeMethods.GetDeviceCaps(dC, &H58)))
Support.m_TwipsPerPixelY = (1440 / CDbl(NativeMethods.GetDeviceCaps(dC, 90)))
NativeMethods.ReleaseDC(NativeMethods.NullIntPtr, dC)
End If
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
ProjectData.ClearProjectError
End Try
Support.m_IsTwipsPerPixelSetUp = True
If ((Support.m_TwipsPerPixelX = 0) OrElse (Support.m_TwipsPerPixelY = 0)) Then
Support.m_TwipsPerPixelX = 15
Support.m_TwipsPerPixelY = 15
VB6Errors.RaiseError(7, Resources.GetResourceString("Misc_SetUpTwipsPerPixel"))
End If
End If
End Sub
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
||||
|
You can reference Microsoft.VisualBasic.Compatibility and use these properties and functions:
Code:
Microsoft.VisualBasic.Compatibility.VB6.TwipsPerPixelX TwipsPerPixelX TwipsToPixelsX(x) TwipsToPixelsY(y)
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
||||
|
I'm not 100% sure why but those methods have been marked obsolete in .NET 4.0, so it's probably best not to rely on them. I'm not sure what that means for upgraded VB6 code.
__________________
![]() 2007, 2008, 2009, 2010 Why is my data not saved to my database? | Communicating between multiple forms MSDN: Data Walkthroughs | "How Do I?" Videos My Blog: Custom Events | Dynamic GDI+ Drawing |
|
||||
|
Quote:
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Tags |
| form measurement units, measurement etc., pixels to twips |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|