1Steps ,
Viperспасибо теперь всё работает. Причём оба способа. Конечно не совсем точно:
1Steps 44,45 x 26,98 см при максимальном разрешение(1680 x 1050) и 40,00 x 30,00 см при разрешение (640x480)
Viper 47,00 x 29,30 см при максимальном разрешение(1680 x 1050) и 21,16 x 15,08 см при разрешение (640x480)
ну а метром 46,50 x 28,7 см
так что функции WinAPI работоспособны при любых разрешениях
- Код: Выделить всё
Public Class Form1
Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceCaps" (ByVal hDC As IntPtr, ByVal index As Integer) As Integer
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hWnd As IntPtr) As IntPtr
Private Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As IntPtr
Public Const HORZSIZE As Integer = 4
Public Const VERTSIZE As Integer = 6
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim hDC As IntPtr = GetDC(IntPtr.Zero)
Dim dX As Double = GetDeviceCaps(hDC, HORZSIZE) / 10
Dim dY As Double = GetDeviceCaps(hDC, VERTSIZE) / 10
ReleaseDC(IntPtr.Zero, hDC)
Label1.Text = dX & " x " & dY
Dim dpix As Double = Me.CreateGraphics.DpiX
Dim dpiy As Double = Me.CreateGraphics.DpiY
Dim rec As Rectangle = Screen.PrimaryScreen.WorkingArea
Dim w As Double = CInt((rec.Width / dpix * 2.54) * 100) / 100
Dim h As Double = CInt((rec.Height / dpiy * 2.54) * 100) / 100
Label2.Text = w & " x " & h
End Sub
End Class