Setting desktop resolution problem

Windows specific forum
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Setting desktop resolution problem

Post by BarryG »

I use this simple code to change my desktop resolution on Win 10:

Code: Select all

res.DEVMODE\dmSize=SizeOf(DEVMODE)
res\dmPelsWidth=800
res\dmPelsHeight=600
res\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT
ChangeDisplaySettings_(@res.DEVMODE,0)
And it works great. But then I used it to change back to 1920 x 1080 (instead of 800 x 600), and it worked great again.

But when my PC rebooted, it was back at 800 x 600, as if 1920 x 1080 didn't get "remembered". Am I supposed to be doing something else?

[Edit] I just saw this -> https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexa and I'm guessing that instead of passing 0 for the last param of ChangeDisplaySettings_(), that I should be specifying #CDS_UPDATEREGISTRY for it? Would that be right?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

Re: Setting desktop resolution problem

Post by RASHAD »

Hi BarryG

Code: Select all

res.DEVMODE\dmSize=SizeOf(DEVMODE)
res\dmPelsWidth=800
res\dmPelsHeight=600
res\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT
ChangeDisplaySettings_(@res.DEVMODE,#CDS_RESET	)
Delay(5000)
res\dmPelsWidth=1920
res\dmPelsHeight=1080
res\dmFields=#DM_PELSWIDTH|#DM_PELSHEIGHT
ChangeDisplaySettings_(@res.DEVMODE,#CDS_RESET)
Egypt my love
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Setting desktop resolution problem

Post by BarryG »

Thanks, I'll give it a test.
Post Reply