Как узнать ширину экрана

Как узнать ширину экрана

Option Explicit Private Const LOGPIXELSX = 88 ' Logical pixels/inch in X Private Const LOGPIXELSY = 90 ' Logical pixels/inch in Y Private Const HORZRES = 8 ' Horizontal width in pixels Private Const VERTRES = 10 ' Vertical width in pixels Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDc As Long, ByVal nIndex As Long) As Long Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDc As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long   Public Sub usbGetFormSize() Dim x As Variant Dim y As Variant Dim hDc As Long, lngRetVal As Long Dim varScreenX As Variant, varScreenY As Variant Dim varPixToInchX As Variant, varPixToInchY As Variant hDc = GetDC(0) 'Get the Screen size in pixels for X & Y varScreenX = GetDeviceCaps(hDc, HORZRES) varScreenY = GetDeviceCaps(hDc, VERTRES) 'Get the conversion of pixels/inch for X & Y varPixToInchX = GetDeviceCaps(hDc, LOGPIXELSX) varPixToInchY = GetDeviceCaps(hDc, LOGPIXELSY) 'Convert to миллиметры. x = varScreenX / varPixToInchX * 25.4 y = varScreenY / varPixToInchY * 25.4 End Sub

Существует вот такой подход к решению, но доверять ему я бы не стал!



Источник: qa-help.ru


Добавить комментарий