Choose form based on display settings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Some of my users are displaying 800 X 600, some are 1024 X 768. Is there a
way of determining their setttings to make judgements about what size form
should be displayed?
 
Create a module, Insert this code and try it, the function should return the
resolution

Option Compare Database
Option Explicit

Public Const RSL_640_480 As Byte = 0
Public Const RSL_800_600 As Byte = 1
Public Const RSL_1024_768 As Byte = 2
Public Const RSL_1152_864 As Byte = 3
Public Const RSL_1280_1024 As Byte = 4
Public Const RSL_1600_1200 As Byte = 5

Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long,
lpRect As RECT) As Long

Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type


Public Function GetScreenResolution() As Byte

Dim R As RECT
Dim hwnd As Long
Dim RetVal As Integer
Dim strRsl As String

hwnd = GetDesktopWindow()
RetVal = GetWindowRect(hwnd, R)

strRsl = (R.Right - R.Left) & (R.Bottom - R.Top)

Select Case strRsl

Case "640480": GetScreenResolution = RSL_640_480
Case "800600": GetScreenResolution = RSL_800_600
Case "1024768": GetScreenResolution = RSL_1024_768
Case "1152864": GetScreenResolution = RSL_1152_864
Case "12801024": GetScreenResolution = RSL_1280_1024
Case "16001200": GetScreenResolution = RSL_1600_1200

End Select

End Function
 
Back
Top