Modifying the screen resolution
Posted on 2004-08-22
I'm trying to modify the screen resolution with Windows API and VB coding (VBA for MS Access).
The fragment of code goes like this:
Private Declare Function EnumDisplaySettings Lib "user32" _
Alias "EnumDisplaySettingsA" _
(ByVal lpszDeviceName As Long, _
ByVal iModeNum As Long, _
lpDevMode As Any) As Boolean
Private Declare Function ChangeDisplaySettings Lib "user32" _
Alias "ChangeDisplaySettingsA" _
(lpDevMode As Any, _
ByVal dwflags As Long) As Long
Public Sub ChangeRes(iWidth As Single, iHeight As Single)
Dim blnWorked As Boolean
Dim i As Long
Dim DevM As DEVMODE
i = 0
blnWorked = EnumDisplaySettings(0&, i, DevM)
i = i + 1
Loop Until (blnWorked = False)
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
.dmPelsWidth = iWidth
.dmPelsHeight = iHeight
Call ChangeDisplaySettings(DevM, 0)
The code works wonders with modifying the screen resolution (change from 800x600 to 1280x1024), however, when the screen res changes, the start menu bar from Windows XP moves up the screen as well. It doesn't seem to want to stay at the bottom of the screen.
The screen looks odd with the start bar in the middle of the screen. I was just wondering whether there's any fixes to this? i.e screen refresh?
Many thanks for any pointers to the right direction!