Peter,
Here is the script I am using. I have added some extra padding to the DEVMODE structure in case there are extra params being written into it, causing corruption.
I have left in some of the diagnostics. (My video has 108 display modes!)
I changed "boolean" to "bool" but this should not cause your problem since the this type would default to "sys"
% CCDEVICENAME = 32
% CFORMNAME = 32
% DM_PELSWIDTH = &H80000
% DM_PELSHEIGHT = &H100000
/*
#define CCHDEVICENAME 32
#define CCHFORMNAME 32
typedef zstring TCHAR
typedef struct _devicemode {
zstring dmDeviceName[32] '0 CCHDEVICENAME
WORD dmSpecVersion '32
WORD dmDriverVersion '34
WORD dmSize '36
WORD dmDriverExtra '38
DWORD dmFields '40
union {
struct {
short dmOrientation '44
short dmPaperSize '46
short dmPaperLength '48
short dmPaperWidth '50
short dmScale '52
short dmCopies '54
short dmDefaultSource '56
short dmPrintQuality '58
} ;
struct {
POINTL dmPosition '44
DWORD dmDisplayOrientation '52
DWORD dmDisplayFixedOutput '56
} ;
} ;
short dmColor '60
short dmDuplex '62
short dmYResolution '64
short dmTTOption '66
short dmCollate '68
TCHAR dmFormName[CCHFORMNAME] '70
WORD dmLogPixels '102
DWORD dmBitsPerPel '104
DWORD dmPelsWidth '108
DWORD dmPelsHeight '112
union {
DWORD dmDisplayFlags '116
DWORD dmNup '116
} ;
DWORD dmDisplayFrequency '120
#if (WINVER >= 0x0400)
DWORD dmICMMethod;
DWORD dmICMIntent;
DWORD dmMediaType;
DWORD dmDitherType;
DWORD dmReserved1;
DWORD dmReserved2;
#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
DWORD dmPanningWidth;
DWORD dmPanningHeight;
#endif
#endif
} DEVMODE, *PDEVMODE, *LPDEVMODE;
*/
Type DEVMODE
zstring dmDeviceName[32] '00 'itr array itr macro
dmSpecVersion as short '32
dmDriverVersion as short '34
dmSize as short '36
dmDriverExtra as short '38
dmFields As Long '40
dmOrientation as short '44
dmPaperSize as short '46
dmPaperLength as short '48
dmPaperWidth as short '50
dmScale as short '52
dmCopies as short '54
dmDefaultSource as short '56
dmPrintQuality as short '58
dmColor as short '60
dmDuplex as short '62
dmYResolution as short '64
dmTTOption as short '66
dmCollate as short '68
zstring dmFormName[32] '70 'itr array itr macro
dmUnusedPadding as short '102
dmBitsPerPel as Long '104 'was short
dmPelsWidth As Long '108
dmPelsHeight As Long '112
dmDisplayFlags As Long '116
dmDisplayFrequency As Long '120
sys reserved[33] '124
'256
End Type
Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As DevMode) As bool
Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As DevMode, ByVal dwflags As Long) As Long
Dim DevM As DEVMODE
Dim a, i, b, TmpW, TmpH As Long
i = 0
Do
a = EnumDisplaySettings(0, i, DevM) '&DevM !
iF a =0 Then Exit Do
i = i + 1
End Do
print "Number of Screen Modes: " i
'----
'cr=chr(13)+chr(10)
'pr="dev data:" cr cr
'long * d : &d=DevM
'for i=18 to 31 : pr+=hex(d[i]) cr : next
'print pr
'----
TmpW = DevM.dmPelsWidth
TmpH = DevM.dmPelsHeight
'print structureof DevM
'print " " tmpw " " tmph
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = 800
DevM.dmPelsHeight = 600
b = ChangeDisplaySettings(DevM, 0) '&DevM !
print "ok"
'previous resolution !
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = TmpW
DevM.dmPelsHeight = TmpH
b = ChangeDisplaySettings(DevM, 0) '&DevM !
'b = ChangeDisplaySettings(0, 0) '&DevM !
print "ok"
Charles