Silly me, I also need to know the code to set the monitor resolution, in case that wasn't clear.
Hello,
You need API calls. Try this: -
Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Sub GetScreenSize()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
If x < 1024 And y < 768 Then
sYourMessage = "This screen is best viewed at 1024 x 768." & vbCrLf
sYourMessage = "Would you like to change the resolution?"
iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen Resolution")
If iConfirm = vbYes Then
'Change screen settings
End If
End If
End Sub
However, it doesn't change the screen resolution. If you change the screen resolution without testing it first it can completely bugger up the monitor. Maybe, you could just suggest that the user changes it themselves?
Regards,
Dax.
Here is a mode to Dax's code which gives the user
access to change the display....safer way as Dax
has commented.
Sub GetScreenSize()
Dim x As Long, y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCREEN)
y = GetSystemMetrics(SM_CYSCREEN)
If x < 1024 And y < 768 Then
sYourMessage = "Current screen size is " & x & " x " & y & vbCrLf
sYourMessage = sYourMessage & "This screen is best viewed at 1024 x 768." & vbCrLf
sYourMessage = sYourMessage & "Would you like to change the resolution?"
iConfirm = MsgBox(sYourMessage, vbExclamation + vbYesNo, "Screen Resolution")
If iConfirm = vbYes Then
'Change screen settings
Call Shell("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3")
End If
End If
End Sub
Ivan