Active Forums => Programs => Topic started by: SpriggsySpriggs on June 02, 2021, 03:50:32 pm
Title: Change Resolution with WinAPI functions
Post by: SpriggsySpriggs on June 02, 2021, 03:50:32 pm
The below code can be used to change resolution for a given monitor in Windows. This was tested on Windows 10 20H2 64 bit using the 64 bit IDE. It does not work in 32 bit as of yet. It requires v1.5 or higher to compile as-is. The code asks for input for which monitor to change (starting with zero as the first), then the width and height to change to.
While EnumDisplaySettings(_Offset(adapter.DeviceName), modeIndex,_Offset(mode))
IfNot targetModeFound And adapterIndex = index Then
If CHANGE_MODE And mode.dmPelsWidth = dispwidth And mode.dmPelsHeight = dispheight And mode.dmDisplayFrequency >=59And mode.dmDisplayFrequency <=60Then
Title: Re: Change Resolution with WinAPI functions
Post by: OldsCool on June 02, 2021, 04:01:58 pm
Thought I'd give it a try. loaded it in QB v1.4. have an IDE error on line 32 - 'Expected variablename AS type or END TYPE...I'll upgrade to latest QB64 version. that may be it?
update...I'm guessing it's the Win7 / 32bit machine I'm using right now...good luck didn't want to waste your time.
Title: Re: Change Resolution with WinAPI functions
Post by: SpriggsySpriggs on June 02, 2021, 04:34:06 pm
Thought I'd give it a try. loaded it in QB v1.4. have an IDE error on line 32 - 'Expected variablename AS type or END TYPE...I'll upgrade to latest QB64 version. that may be it?
@OldsCool Oh, this code would require at least stable build v1.5 to compile due to the newer way of declaring variables. You can get the latest stable or the dev build for your Windows 7 machine still.
Title: Re: Change Resolution with WinAPI functions
Post by: OldsCool on June 02, 2021, 06:10:48 pm
Awesome, thanks. I can see many uses for this. I'll upgrade (thought so...) and try it.
Title: Re: Change Resolution with WinAPI functions
Post by: OldsCool on June 02, 2021, 06:18:27 pm
I just read the second line of your previous post, missed it somehow...Older QB64 versions have been running flawlessly on my Win7/32 machine. I was mostly wondering about the compatibility of your routine with Win7 itself, i Figured the error I was getting was a version issue. if you're still interested I'll let you know how it goes once I upgrade, thanks again .
Title: Re: Change Resolution with WinAPI functions
Post by: SpriggsySpriggs on June 02, 2021, 06:36:36 pm
@OldsCool I actually updated the post after you mentioned it. You didn't miss anything. Glad you are showing some interest in the thread, though
Title: Re: Change Resolution with WinAPI functions
Post by: SpriggsySpriggs on June 02, 2021, 08:02:01 pm
@OldsCool You can forget trying to run it as a 32 bit executable. The code doesn't currently work in 32 bit. I tried it myself on another computer. Oh well. 64 bit is the more common build of Windows anyways