Jump to content
  • Advertisement
Sign in to follow this  

Changing windows resolution temporarly

This topic is 4624 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, My question is about making the computer change its resolution to (800x600 for example) as i enter the program. and back to the original resolution as i exit the program (CORRECTLY OR BY END-TASK etc...). I know how to set back the resolution when i end my program correctly, but this is not enough. The program may crash or simply the power can be cut off from the house while the user is running my program on his computer, so when he turns on the computer again, he will find his desktop's resolution weird. does anyone know a solution? N.B. without directx nor openGL :) and i'm using VB.net as an alternative for this.. another good solution for me can be a strechable windows form that looks exactly the same on different resolutions. can this be done? thanx alot :)

Share this post

Link to post
Share on other sites
From a usability point of view, changing resolutions is a Bad Thing(tm).

LCDs for example handle only one resolution well. Some monitors take a while to readjust to new resolution. User might not have the image h/v centered for your specific resolution, etc. Alt-tabing will not cause problems. It can rearange desktop icons. Also, messing with system settings is generally one of the worst things you can do.

The only "allowable" resolution changing by the application is usually limited to full screen exclusive applications (DirectX, OpenGL).

As for making application look the same on every screen, this isn't without downsides either.

Icons do not scale well, fonts will generally have problems adjusting precisely to exact resolution, users might have their font preferences set differently, they might be using font which does not scale as you need it to, rounding errors may exhibit strange artefacts, it may interfere with accesibility and similar.

When doing this, you need to work out the screen dimensions, the resolution of fonts for that screen (96, 120 or custom dpi), then based on those values recreate your window, adjust the font sizes in all controls, and set proper sizes.

I do not know exactly how this would be done in VB .Net, but I've done similar under Delphi (which, at least regarding components, has similar structure and design). I defined my entire GUI in "metric" units, then when I had to create the GUI, I'd just apply a transformation from metric to screen dimensions. This way, if my application had a button "2cm by 1cm", it looked the same on all screens.

The reason I did this, is because despite several windows API methods provided for just that, they were extremly unreliable, especially with regard to font sizes. Some of the scaling functions also incorrectly (either due to user settings or internationalization differences) converted between screen resolutions, which resulted in GUI being completely broken on some systems.

My general advice would be not to do it, but if you have to, you'll need to look into manually configuring the GUI on launch.

Share this post

Link to post
Share on other sites
Pass CDS_FULLSCREEN into the dwFlags parameter. That tells Windows that it's a temporary change and the resolution should be reset no matter what.

Share this post

Link to post
Share on other sites
Antheus, thanks alot for your help and time. Promit, you got it man! i just did exactly what you said and it worked just fine and exactly as i wanted.. thanx for your care to both of you :)

and for the people that will read this forum and use VB.net, you pass the integer 4 or &H4 instead of writing CDS_FULLSCREEN to be understood by the VB.net compiler.

the integers (longs) that resemble dw.flags are written as follows:

CDS_FULLSCREEN is &h00000004
CDS_GLOBAL is &h00000008
CDS_NORESET is &h10000000
CDS_RESET is &h40000000
CDS_SET_PRIMARY is &h00000010
CDS_SETRECT is &h20000000
CDS_TEST is &h00000002

Thanks again people, I really didn't know anything about this dw.flags although it seems to be one of the basics that everyone should know :)

(the function to pass this parameter to is ChangeDisplaySettings by the way)

Private Declare Auto Function ChangeDisplaySettings Lib "user32.dll" ( _
ByRef lpDevMode As DEVMODE, _
ByVal dwFlags As Int32 _
) As Int32

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!