desktop Screen resolution change?

BlitzMax Forums/BlitzMax Beginners Area/desktop Screen resolution change?

Juiceter(Posted 2016) [#1]
Is there any way to do this?:

I am using the GUI (windowed mode) but what to be able to change the users display mode from whatever it's set at (usually higher) down to 800x600 so that the window fills more of the screen (i.e. is more optimal) and the users desktop is changed to 800X600 resolution (naturally).


Any pointers? Thanks.


Bobysait(Posted 2016) [#2]
Probably useless.

If you're using maxgui, just set your window to be resizable, the user will do what he wants ; maximize/reduice the windows and if he really wants, he'll change his screen resolution by himself.

Except for a fullscreen game, and only with a disclamer and a previous check that the resolution is available, you should never impose a resolution to the user.

Just to mention, if I launch an app that resizes my desktop to this kind of resolution just because the developper can't optimize his stuff to fit on my 1920*1080 (which, nowadays, is a standard for desktop), I'll first remove the application and then if possible, I 'll Yell at the author, because it's intrusive, frustrating and, seriously risky -> small resolutions worked on old computers, but now this kind of resolution imply graphical changes and more to think the screen won't support it ... And occasionnaly won't get back to the previous mode ... or worse ... computer freezes).


Juiceter(Posted 2016) [#3]
The thing is that I want to make it easy for the user to maximise the window size so that it's easier to see (its actually a map editor which mirrors the game as a wysisyg). I what to be able to change between the native resolution that he's running his desktop at and the optimal resolution for the window.

Note that there is the option to resort back to the screen-mode the user was using before! I'm sure there is a way to do it, but it's probably rather involved. Still, I want to be able to do it because its something useful.

Thanks for your comment anyway!


grable(Posted 2016) [#4]
Heres something i had lying around :p
Check the bottom for the interesting parts. Windows only.



FireballStarfish(Posted 2016) [#5]
I'll first remove the application and then if possible, I 'll Yell at the author, because it's intrusive, frustrating and, seriously risky

I have to agree. If some application changed my desktop resolution, especially without clearly asking beforehand, I would get very angry. I could also easily see that causing irreversible effects, like resizing windows, rearranging desktop icons, making other programs that can't deal with the resolution change crash...


TomToad(Posted 2016) [#6]
Never, ever change the desktop resolution. It can create a host of problems. Instead, resize the window to fit the desktop and scale everything accordingly.



RustyKristi(Posted 2016) [#7]
Never, ever change the desktop resolution. It can create a host of problems.


Does it apply on Blitz3D as well?


TomToad(Posted 2016) [#8]
It applies on anything. The user has set that resolution for a reason. Changing the resolution will at best move all the desktop icons around and resize windows, at worst could crash programs or even the system if the resolution is not supported.

Changing resolution in fullscreen programs with DirectX or OpenGL is ok as Windows is designed to deal with those cases, but changing the desktop itself is a big no-no.


Juiceter(Posted 2016) [#9]
In my case this is not true for a number of reasons; that's why I want to do it!

Here's why.

1. The program is meant to be used by me/a few people only for map generation.

2. I change my res all the time (from the desktop). The worst I've ever had happen to me is that you have to move a few icons around on resize. The fact that you are able to change the resolution from the desktop suggest that YOU CAN do it without crashing things (you check of course, that your gfx card can display the necessary mode). Now if you are talking from the standpoint of doing it through blitzmax then you may just be right (I don't know enough about it which is why I'm probing you guys for some info here).

If you resize the window, the graphics WILL NOT resize, or if you make it so that they are resized via scaling (i.e. the user drags the window to be as big as possible) they will look rather ugly (I suppose you could force it to only "double" or "tripple" up but then all this requires much more coding). I don't want to go the scaling way. Giving the user the OPTION (read OPTION) to change resolution down to 800*600 (a little old-fashioned but still a well supported resolution) and an alternative to go back to his native resolution within a menu (and to default back to his native resolution at the end of the program) is all I'm looking for here (nice and simple in coding terms).

So while it may indeed create problems, that's what I want to do. So please don't say never ever - there's a reason for it. If I work out how to post a screenshot, what I'm trying to do will probably be much clearer.

Nevertheless thanks for all your input.


Juiceter(Posted 2016) [#10]



grable(Posted 2016) [#11]
Are you guys serious??
Changing resolutions wont crash your app nor will it mess with your icons or stay in that resolution, unless you want it to that is.

What do you think OpenGL games does to go fullscreen? They call the exact same API that Windows itself uses from its "Change Resolution" dialogs.
So im sure if that many games manage to do it correctly, we can too :p

Now about randomly changing resolutions without the users permission i can agree with. But the rest sounds like cyber superstition or something.


Juiceter(Posted 2016) [#12]
I tend to agree with you grable, and thanks for you snippet of code above by the way.

I just see it from the point of view that the way I want to do it is more elegant than having to spend more time resizing things (using more memory/taking more time to code it when I could be working on what I'm actually aiming for without such things getting in the way).

And that's really the whole point of blitz, isn't it? To make things easier for us. So some of you may frown upon it and say it's not the right way to do things. But as you know, there are so many ways to achieve something; this seems the logical way for me to achieve it for this particular app.

If blitz provides a way to do it (through openGL or whatever) then, well, it's there to be exploited.

It just seems to be a neat way of bringing down everyone's common resolution to that of the app rather than having to resize everything for the convenience of what ever one of the multiple possibilities of screenmodes that everyone will be running.

Of course, if you look at the graphic above THE CHOICE IS GIVEN TO THE USER AS TO WHETHER HE WANTS TO OPTIMISE THE WINDOW OR NOT! So I wouldn't be forcing anyone working in a high res mode not to squint at the window which doesn't need so high a resolution!

BTW, I run 1280 by 1024 as standard (on my old 17 inch monitor).

Perhaps some of you are coming from the point of view that you may be running a lot of programs at once (some of which my not like the lower resolution and crash) so yes I get what you are getting at. Me? I tend to only have 1 or 2 working windows open at a time. We're all different ;-)


Bobysait(Posted 2016) [#13]
What do you think OpenGL games does to go fullscreen? They call the exact same API that Windows itself uses from its "Change Resolution" dialogs.
So im sure if that many games manage to do it correctly, we can too :p


You're wrong.
A fullscreen application that changes the resolution will not move icons (and here, let's not talk about the ones that resizes very badly and explode your desktop icons... but let's speak only about thoose who don't) only if there is only one screen (else it will) because it saves the current state of the desktop to restore it while the application close, while a desktop modification will modify everything anytime an icon doesn't fit the desktop area.

Now about randomly changing resolutions without the users permission i can agree with. But the rest sounds like cyber superstition or something.


Yes, it's just my old computer that wasn't aware of superstitions, so it's probably a psycho-effect that it froze any time I tried to set the resolution.

On low-cost computers or on slow computers, a blitz3d game that goes fullscreen in an unsupported mode can lead to a not-responding computer.
There is even no certainty the previous resolution will be restored.
All the internal stuff make the best to get it working, but it's not 100% safe.

(and an unsupported fullscreen "Graphics X,Y" will just lead to a runtime error after trying to modify the resolution. So, the "restore" part won't be called in your program)


Anyway,
@Juiceter :
You want to have your application to fit the screen ? Use the window size with maxgui (then set it to maximized)
For the graphics, you just have to use "SetScale" to zoom/unzoom your stuff to fit the screen (or use the virtualresolution)

It's the proper way to do it, so you might probably want to get used to it for a later more deployed stuff.

You can track the window size with the EVENT_WINDOWSIZE id
While PollEvent()
 Select EventId()
   Case EVENT_WINDOWSIZE
     Screen_Scale# = ClientWidth(MyWindow)/MyDesiredWidth
     ' or based on Height
     Screen_Scale# = ClientHeight(MyWindow)/MyDesiredHeight
Wend

' on top of your drawing stuff
SetScale Screen_Scale, Screen_Scale


So, there is really no need to resize the desktop, you just resize the window.

Whatever, if you persist to resize the desktop (and if it's for windows only) there is all the needs in the windows API
-> EnumDisplayDevices will list the devices (ie: screens)
-> EnumDisplaySettings will list the modes available for the device (width, height, depth)
-> ChangeDisplaySettings ... will modify the desktop


ps : And of course, if you use this, be sure I'll never test anything you post, you're aware that most of us don't like application that plays with the desktop resolution.
There is nothing personnal, for Blitz3D users, it's the same - when someone post a code that use "Graphics/Graphics3D 800,600,0,1" I'm here to yell at him if he was aware.


TomToad(Posted 2016) [#14]
What do you think OpenGL games does to go fullscreen? They call the exact same API that Windows itself uses from its "Change Resolution" dialogs.
So im sure if that many games manage to do it correctly, we can too :p

Not true. When you make an OpenGL call or DirectX call, Windows will save the current state of the desktop and hand control of the screen to the program. When the program is done, Windows will restore the desktop back to its original state.

When you change the actual desktop resolution, like with the video properties dialog, Windows will rearrange the icons and resize windows to fit. The old state is not saved. Even if you change back to the original resolution, the windows will remain resized and icons will only revert if they were on auto-arrange. If you had the icons set manually to where you would like them, then you will be stuck moving them back by hand.

The desktop is the user interface into the operating system. The program contains it's own user interface. The desktop should not be modified to match your program, rather your program should be modified to match the desktop.

If resizing the windows makes things too ugly, you can always have a "preview fullscreen" option. There you would set up a graphics display with Graphics 800,600,32 . This way you can use the actual resolution without messing with the desktop itself.




grable(Posted 2016) [#15]
Not true. When you make an OpenGL call or DirectX call, Windows will save the current state of the desktop and hand control of the screen to the program. When the program is done, Windows will restore the desktop back to its original state.

That may be true for DirectX, which has its exclusive access options.
But not so for OpenGL, which has NO api to change the resolution of the screen.
Which is why GLMax2D uses that function for example.

When you change the actual desktop resolution, like with the video properties dialog, Windows will rearrange the icons and resize windows to fit. The old state is not saved. Even if you change back to the original resolution, the windows will remain resized and icons will only revert if they were on auto-arrange. If you had the icons set manually to where you would like them, then you will be stuck moving them back by hand.

Thats true, but only because that dialog has no TEST function. I seem to remember back in the day that it popped up a window giving you 15 seconds to cancel it at which point it would reset all windows and icons back to the original state (or do the resizing and moving after those 15 seconds), but that is no longer the case.
Still, that dialog does nothing magical!

The desktop is the user interface into the operating system. The program contains it's own user interface. The desktop should not be modified to match your program, rather your program should be modified to match the desktop.

And this is somehow worse then when a game does it?? I see no difference between a game going fullscreen by changing the resolution and an application doing the same, whether you maximize the window or not.

Hey dont take my word for it, dig a little deeper into GLMax2D or any other OpenGL game and youl see what i mean.
And if you still dont believable me, try hooking that API and see who calls it yourself.


Bobysait(Posted 2016) [#16]
@grable : Juiceter didn't mention about opengl.
We're trying to be generic, so we're not taking opengl apart...

And by the way, running an opengl 3d context (in blitzmax) on a dual screen desktop with the application using a different resolution that my primary screen, and all I can see is the image on the first screen that is partially seen on the second screen.
Then if I use Alt+Tab without closing the fullscreen application, I go back to a resized desktop and fully reorganised icons, and ... it also removed my wallpaper.

So, whatever OpenGL doesn't call any API function for fullscreen, the windows drivers will.


grable(Posted 2016) [#17]
@grable : Juiceter didn't mention about opengl.
Except he just did.

And no need to take OpenGL apart, just search for ChangeDisplaySettings in "/brl.mod/glgraphics.mod/glgraphics.win32.c".

And by the way, running an opengl 3d context (in blitzmax) on a dual screen desktop with the application using a different resolution that my primary screen, and all I can see is the image on the first screen that is partially seen on the second screen.
Then if I use Alt+Tab without closing the fullscreen application, I go back to a resized desktop and fully reorganised icons, and ... it also removed my wallpaper.

So your saying that even GLMax2D messes up your desktop? Maybe that has something to do with multiple monitors... I only have one so am unable to test.

So, whatever OpenGL doesn't call any API function for fullscreen, the windows drivers will.
No it wont. Only thing OpenGL cares about is making a context attached to a window. Thats it. There is NO WAY to tell opengl what screen resolution you want. Therefore the drivers cant to anything.

Im not pulling this out of my ass here, its all over the internet if you bother to search for it.


Juiceter(Posted 2016) [#18]
Well thanks one and all. Interesting comments there.

Not sure if you guys have read what I've said though - it's probably only going to be me that's using this app; so I won't be releasing any code for anyone to test. If it works for me then it will be fine. Interesting lines of thought, though.


Bobysait(Posted 2016) [#19]
@grable : OpenGL (from Blitzmax or not) creates a context. if you want it to be fullscreen you have to modify the desktop resolution to fit its window.
Then line 117 "if( ChangeDisplaySettings( &dm,CDS_FULLSCREEN )==DISP_CHANGE_SUCCESSFUL )"

I'm a bit lost in the conversation ...
All I can see is that actually Blitzmax changes the display mode to get the opengl context in fullscreen mode. So, what's your point ?

BTW, I think perhaps you don't understand (maybe I'm just not clear, I don't fully master the english language ^^) that I (we ?) don't bother anyway if it comes from opengl or windows or a graphics driver or blitzmax, in the end, the resolution is still modified at some step until the application ends.
And that's all what I'm speaking about, because, wherever the problem is, it's still there.
So, we should never intend to modify the display unless really advert the user.
The side effects are legions, because, while it's supposed to be safe, it has never been. It's a process that can break at so many moment that it's actually trully unsafe.
When you do it to launch a game, you already know it will, and generally, you have a windowed launcher that allows to set the good resolution and choose or not to go fullscreen.


@Juiceter:
No problem. I really think you should try a virtual resolution, at least you'd learn how to master it, but if you want to go for fullscreen, it's obviously up to you.
Then you probably have what you need on this topic.
And as I said above, what I said is really not something to take personnal.


ps :
@grable : Juiceter didn't mention about opengl.
Except he just did.

Don't think I'm trying to proove anything, but I really can't see where he did. So, sorry if I might have missed it
The only one I can find related to opengl by Juiceter is :

If blitz provides a way to do it (through openGL or whatever) then, well, it's there to be exploited.


And honnestly, I don't think it's relevant in what we said so there must be something else I missed.


grable(Posted 2016) [#20]
All I can see is that actually Blitzmax changes the display mode to get the opengl context in fullscreen mode. So, what's your point ?

My point is that OpenGL itself does not change the resolution, it has to be done from an API like ChangeDisplaySettings.
Which is the same API used by Windows itself to change resolution (except for DX, which is at a lower level).

All im saying is that there is NO DIFFERENCE, between YOU calling ANY api to change the resolution and ANYTHING ELSE doing the same.
Its the same thing.
So if one of them is wrong, the other is right, where does that leave us?

Don't think I'm trying to proove anything, but I really can't see where he did. So, sorry if I might have missed it

Its in post #14.

And note that i never said one should do this on a lark which you seem to think. You change the resolution because the user wanted to, thats it.

These worries about screen resolution changes being "dangerous" is a past long gone!
I havent had any trouble with doing that for 16+ years, and i threw out my CRT last year even.


Bobysait(Posted 2016) [#21]

Its in post #14.


Ok, so it's not from Juiceter, it's from TomToad.


These worries about screen resolution changes being "dangerous" is a past long gone!
I havent had any trouble with doing that for 16+ years, and i threw out my CRT last year even.


You're like many other, a lucky one.
We are not all as lucky, so we know it can be really annoying, and it's far from a "past long gone".


grable(Posted 2016) [#22]
You're like many other, a lucky one.
We are not all as lucky, so we know it can be really annoying, and it's far from a "past long gone".

If your going to phrase it like that, you should say your the unlucky one.
IE screen resolution changes messing up your system is the exception not the rule.

I would much like to know what kind of hardware you have and how old the drivers are if this is a problem for you. Really.


Juiceter(Posted 2016) [#23]
In retrospect, "upscaling" is probably the way most would do it (and probably safer too for the reasons given). However, it just seems to me that it isn't very, shall we say, graceful.

- you are adding more code, which slows development down

- you are using more resources (more memory, and more code means slower execution time).

You can look at it from that point of view too. Ok, perhaps they result in minor hits on performance due to the power of todays PCs etc. but I was brought up coding on the Amiga, and as such I tend to try and code in such a way that I do things "tightly" (it's just a habit).

It's a pity that you can't just change desktop screenmode and when you are finished have the users screenmode re-invoked (with all icons in their original places).


grable(Posted 2016) [#24]
It's a pity that you can't just change desktop screenmode and when you are finished have the users screenmode re-invoked (with all icons in their original places).
You can though. So long as you keep the process that changed the resolution running it should reset when it terminates.
(on Windows atleast, and assuming you used the API correctly)


Juiceter(Posted 2016) [#25]
Yep!


Bobysait(Posted 2016) [#26]

If your going to phrase it like that, you should say your the unlucky one.


Not that much, you just don't care about one thing :
We are not all based on the American stuff.
In France, we have not the same electrical outlet, nor the same output power, and all the hardware is calibrated for US standard. All we have here is some derived stuff that fit our electrical supplies, but it's still made to work with higher voltage.
It leads to monitor flickering from time to time, and lots of power supply that fail just because of overvoltages on the lines.
(some Frenchies are more lucky than others, like in Paris, they have good tensions on their lines)

So, anytime you require a bit more supply than necessary, you take a risk. And this risk is here anytime you switch the monitor resolution, anytime you restart the computer, or anytime you run a game that alternate between high and low polygon density (with a high end GPU, it can goes from 30W to 500W ... it's too much for the lines).

I have an external voltage regulator, but it's not enough for my PC (it's limited to 500 Watt and my PC can go up to 800 Watt)

Then, There is a lot of failure with french hardware, it's not an "unlucky" thing but more something we have to deal with.
As you probably don't read the french news about hardware, you're just not aware of that.
And I highly suppose France is not the only country with this problem (I think germans maybe too ?)


grable(Posted 2016) [#27]
you just don't care about one thing

Well i didnt know your country had a shit electric system, so how can i not care about something i didnt know?

And im not American either, dont know what gave you that idea.

500 Watts is your maximum draw??? Holy shit man, that must suck. No stove, very little heating and maybe a flatscreen if your lucky.
I though middle Europe had better tech, guess i was wrong on that one.

I live in Norway, and we have a generally good electric system. Though there are places with old networks that exhibit the same problems as you have.
And i have lived in such places, and never have i ruined that much hardware! So i know what your talking about.

But that still does not make it a hardware problem, its an electric one.
Given enoughthe required amount of juice your hardware would be able to change resolutions like its supposed to.

So that era really IS long gone, you just didnt notice.

EDIT: I guess im being a pedant at this point, so dont take it the wrong way ;)


Juiceter(Posted 2016) [#28]
I swear by a decent surge protector. Everyone should have all their delicate kit linked up to one.

I have to say that I hated my old 17 inch Amiga multisync monitor switching screenmodes (it had a reed switch in it, and used to give a massive click every time it did so). It were pretty scary I tell thee!


Bobysait(Posted 2016) [#29]

Well i didnt know your country had a shit electric system, so how can i not care about something i didnt know?


Yep, That's what I said, when you don't know about it, you can't figure it.
Well, all installations in France are not that bad, and it's supposed to use the NF (which is almost in all terms the same as the EU norms) but there are too many overvoltages due to, maybe too old electric centrals and not enough maintained wire network ... "when you're not in Paris"

And BTW, norway and Sueden have very good feedbacks, so you're maybe a lucky one to live there :)
While I supposed Norway also use 230V with 50 hz, there is much to think it's just better installed.

All province region that is not Paris just suck a bit ... worse electric installement, bad internet, or late to be installed, less work available, almost no R&D society ...
Even the foreigners only talk about Paris ... (or the Normandy's Omaha Beach for some reasons -_-')
I'm maybe a bit exagerating but that's how I feel it and most of my neighboors too.


500 Watts is your maximum draw??? Holy shit man, that must suck. No stove, very little heating and maybe a flatscreen if your lucky.


Nope, that's just the maximum my box support.
I don't know the word in english and can't find it on google -> in French it's called "Onduleur".
It allows to anticipate voltage ruptures and overvoltages, it's pretty accurate and I've never had any electic problem when I used to use it
But, I just can't plug my computer on it anymore because of its 500 watt max capacity.
For the little story, I used to use it before with my old computer. I had too much charge on it when I plugged my laptop, so I disconnected the old computer and plugged it directly on the mural outlet.
It fried in the same week. So I built a new computer, more powerfull ...

I've moved several times, and different cities, and always experienced electrical problems, with different hardwares. And when I talk to friends of thoose problems when they happen, there is always someone to answer "Oh, that remind me when it happenned to me for [...]"

France is not supposed to be a bad country, or a poor contry, but I think maybe, French are too snooty to admit we live with too many old devices, and tons of things are going very wrong.

[edit]
"surge protector", maybe that's near the word I looked for.
But google just shows me some external outlet ... so it's maybe a bit far to what I'm refering.

-> https://www.amazon.fr/Infosec-65522-Zenergy-Onduleur-prises/dp/B004QQW1MO
That's what i'm talking about.

Now, I'm looking for a 1000 Watt (or more) version.
something like this (but this one is too expensive)
https://www.amazon.fr/KOENIG-Onduleur-USV-2000-1200/dp/B00651UWS8/ref=sr_1_2?ie=UTF8&qid=1472670882&sr=8-2&keywords=onduleur+1200w


grable(Posted 2016) [#30]
Internet says UPS, external power supply with a battery. Which makes more sense now.
Not a bad thing to have, especially where you live hehe.

Heres hoping that 1000watter solves your power issues :)