LeeOgley
asked on
Changing Screen Resolution/Frequency
Hi,
I am trying to write a small VB program that a user can just double click and the users screen resolution will toggle between 1400x1050 @ 60Hz and 1280x1024 @ 75Hz.
The machine is a laptop, and the laptops is optimised by 1400x1050 display, where as when it is docked the user is using a LG LCD display which is optimised at 1280x1024, running at different resolutions provides poor results
The code below is what I am using.
-------------------------- ---------- ---------- ---------- --
Dim DevM As DEVMODE
Dim lScreenHeight As Long
'Get the info into DevM
erg& = EnumDisplaySettings(0&, ENUM_CURRENT_SETTINGS, DevM)
lScreenHeight = GetSystemMetrics(SM_CXSCRE EN)
If (lScreenHeight = 1280) Then
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY
DevM.dmPelsWidth = 1024 ' ScreenWidth
DevM.dmPelsHeight = 768 ' ScreenHeight
DevM.dmDisplayFrequency = 70 ' Frequency
Else
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY
DevM.dmPelsWidth = 1280 ' ScreenWidth
DevM.dmPelsHeight = 1024 ' ScreenHeight
DevM.dmDisplayFrequency = 60 ' Frequency
End If
erg& = ChangeDisplaySettings(DevM , CDS_UPDATEREGISTRY)
-------------------------- ---------- ---------- ---------- --
The code works but does not seem to retreive or set the display frequency correctly.
Any advice/comments would be appreciated
Lee.
I am trying to write a small VB program that a user can just double click and the users screen resolution will toggle between 1400x1050 @ 60Hz and 1280x1024 @ 75Hz.
The machine is a laptop, and the laptops is optimised by 1400x1050 display, where as when it is docked the user is using a LG LCD display which is optimised at 1280x1024, running at different resolutions provides poor results
The code below is what I am using.
--------------------------
Dim DevM As DEVMODE
Dim lScreenHeight As Long
'Get the info into DevM
erg& = EnumDisplaySettings(0&, ENUM_CURRENT_SETTINGS, DevM)
lScreenHeight = GetSystemMetrics(SM_CXSCRE
If (lScreenHeight = 1280) Then
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY
DevM.dmPelsWidth = 1024 ' ScreenWidth
DevM.dmPelsHeight = 768 ' ScreenHeight
DevM.dmDisplayFrequency = 70 ' Frequency
Else
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY
DevM.dmPelsWidth = 1280 ' ScreenWidth
DevM.dmPelsHeight = 1024 ' ScreenHeight
DevM.dmDisplayFrequency = 60 ' Frequency
End If
erg& = ChangeDisplaySettings(DevM
--------------------------
The code works but does not seem to retreive or set the display frequency correctly.
Any advice/comments would be appreciated
Lee.
ASKER
Increasing points to 200 as really need help on this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way a simple sub could be:
Private Sub CheckRes()
Dim TWIPX as long
Dim TWIPY as long
TWIPX = Screen.TwipsPerPixelX
TWIPY = Screen.TwipsPerPixelY
If Screen.Width \ TWIPX > 1280 Then 'Screen Res Higher than 1280 wide
Call ChangeRes(1280, 1024, 75)
Else 'Switch to 1400 mode
Call ChangeRes(1400, 1050, 60)
End If
End Sub
This would switch between the 2 modes as you requested.
Private Sub CheckRes()
Dim TWIPX as long
Dim TWIPY as long
TWIPX = Screen.TwipsPerPixelX
TWIPY = Screen.TwipsPerPixelY
If Screen.Width \ TWIPX > 1280 Then 'Screen Res Higher than 1280 wide
Call ChangeRes(1280, 1024, 75)
Else 'Switch to 1400 mode
Call ChangeRes(1400, 1050, 60)
End If
End Sub
This would switch between the 2 modes as you requested.
listening
learning...
studying...
To ProgramIt,
I try your code but doesn't work for Windows XP ?->
I try your code but doesn't work for Windows XP ?->
Greetings.
This question has been locked with a Proposed Answer, and remains open today.
If the Proposed Answer did not serve your needs, please reject it and comment with an update. If the Proposed Answer helped you, please accept it to grade and close this question. If you need help splitting points between multiple experts, please comment here with details so we can help you.
EXPERTS -> Please guide me here in terms of closing recommendations if the Asker does not respond in 4 days.
Thanks to all,
Moondancer - EE Moderator
This question has been locked with a Proposed Answer, and remains open today.
If the Proposed Answer did not serve your needs, please reject it and comment with an update. If the Proposed Answer helped you, please accept it to grade and close this question. If you need help splitting points between multiple experts, please comment here with details so we can help you.
EXPERTS -> Please guide me here in terms of closing recommendations if the Asker does not respond in 4 days.
Thanks to all,
Moondancer - EE Moderator
ASKER
Cheers