Change screen resolutionTag(s): WinAPI/Registry


[Local external function declaration]
FUNCTION long ChangeDisplaySettingsA (ref devmode lpst, ulong Flags) &
    LIBRARY "USER32.DLL"

[structure definition, devmode]
character   dmdevicename[32]
integer     dmspecversion
integer     dmdriverversion
integer     dmsize
integer     dmdriverextra
long        dmfields
integer     dmorientation
integer     dmpapersize
integer     dmpaperlength
integer     dmpaperwidth
integer     dmscale
integer     dmdefaultsource
integer     dmprintquality
integer     dmcolor
integer     dmduplex
integer     dmresolution
integer     dmttoption
integer     dmcollate
character   dmformname[32]
integer     dmlogpixels
long        dmbitsperpel
long        dmpelswidth
long        dmpelsheight
long        dmdisplayflags
long        dmdisplayfrequency
long        dmicmmethod
long        dmicmintent
long        dmmediatype
long        dmdithertype
long        dmreserved1
long        dmreserved2

[Instance variable declaration]
Ulong  CDS_FORCE  = 8*16*16*16*16*16*16*16
long  DM_BITSPERPEL_H = 4*16*16*16*16
long  DM_PELSWIDTH_H = 8*16*16*16*16
long  DM_PELSHEIGHT_H = 16*16*16*16*16
long  DM_DISPLAYFLAGS_H = 2*16*16*16*16*16

[powerscript to switch to 800x600]
devmode dm
long a

dm.dmPelsWidth = 800
dm.dmPelsHeight = 600
dm.dmBitsPerPel = 16
dm.dmFields = DM_PELSWIDTH_H + DM_BITSPERPEL_H
dm.dmSize = 188
a = ChangeDisplaySettingsA(dm, CDS_FORCE)

[powerscript to switch to 1024x768]
devmode dm
long a

dm.dmPelsWidth = 1024
dm.dmPelsHeight = 768
dm.dmBitsPerPel = 16
dm.dmFields = DM_PELSWIDTH_H + DM_BITSPERPEL_H
dm.dmSize = 188
a = ChangeDisplaySettingsA(dm, CDS_FORCE)
Here you can download a devmode structure and a test window. Just import them in a PBL and run the window.
blog comments powered by Disqus