Page 1 of 1
Window goes to maximum after monitor turned off and on again
Posted: Mon Aug 25, 2025 7:25 pm
by Lord
Hi!
Today I observed an unsual window behaviour:
Code: Select all
OpenWindow(1, 10, 10, 1024, 920, "", #PB_Window_SystemMenu)
; WindowBounds(1, 1024, 920, 1024, 920)
Repeat
Event=WaitWindowEvent()
Until Event=#PB_Event_CloseWindow
Running this snippet and turning monitor off and on again lets
expand the window to maximum monitor size.
Enabling WindowBounds prevents this.
I didn't never see this before.
I don't want to resize the window, so I don't use
- #PB_Window_MinimizeGadget
- #PB_Window_MaximizeGadget
- #PB_Window_Maximize
- #PB_Window_Minimize
- #PB_Window_SizeGadget
Is this normal behaviour that I just haven't notice before?
I'm still using PB 6.20 x64 on Win11.
Re: Window goes to maximum after monitor turned off and on again
Posted: Mon Aug 25, 2025 8:59 pm
by Olli
Can you clarify how you turn the screen off and on again?
Re: Window goes to maximum after monitor turned off and on again
Posted: Mon Aug 25, 2025 9:59 pm
by Lord
Using the monitors power switch.
Re: Window goes to maximum after monitor turned off and on again
Posted: Mon Aug 25, 2025 10:07 pm
by Paul
Ya, pretty sure it's not suppose to do that since no other apps that are open "auto maximize" when monitor is power cycled.
Just a note... depending on the compiler version I use, older versions will cause the window to get smaller and smaller (instead of maximizing) every time the monitor is power cycled.
Re: Window goes to maximum after monitor turned off and on again
Posted: Tue Aug 26, 2025 4:05 am
by TassyJim
I could confirm the problem.
adding #PB_Window_SizeGadget fixed it for me.
If you want to prevent users resizing, you can detect the resize with #PB_Event_SizeWindow and restore the size.
Jim
Re: Window goes to maximum after monitor turned off and on again
Posted: Tue Aug 26, 2025 9:00 am
by Lord
Thank you to all of you for confirming my observation.
So its not only my system with this strange behaviour.
I will stay with WindowBounds(). It serves me as I do not need
any resizing and I do not have to intercept any events.
Another question is wether this is PB only related and maybe
a bug or not?
Re: Window goes to maximum after monitor turned off and on again
Posted: Wed Aug 27, 2025 4:24 am
by TassyJim
I think that Windows reverts to a default size of 1024 x 768 when it looses connection to the monitor.
This forces your window to full screen and then when the monitor is restored, the full screen stays full screen.
When I tried your code with 1024 x 750, it survived the monitor loss correctly.
When I tried 1024 to 800, it remained at full screen.
30 years ago, this caused desktop icons to get rearranged when it defaulted to 640 x 480.
At least something has improved over the years.
Jim
Re: Window goes to maximum after monitor turned off and on again
Posted: Wed Aug 27, 2025 8:27 am
by Lord
Hi Jim!
Yes, Windows is behaving strangely. At first, it looked as if y=900 was a limit
beyond which the window would expand to its maximum size.
When I then reduced the window size again, the window was still enlarged.
I had to go back to <= 600 until I had a constant window size again.
I give up. I'll stick with WindowBounds().
It's definitly a windows thing.
Re: Window goes to maximum after monitor turned off and on again
Posted: Wed Aug 27, 2025 12:16 pm
by Olli
Lord wrote: Mon Aug 25, 2025 9:59 pm
Using the monitors power switch.
Could you test a softwared switch off ?
Re: Window goes to maximum after monitor turned off and on again
Posted: Wed Aug 27, 2025 2:37 pm
by RASHAD
Hi
For Olli
Code: Select all
OpenWindow(1, 10, 10, 1024, 920, "", #PB_Window_SystemMenu)
; WindowBounds(1, 1024, 920, 1024, 920)
ButtonGadget(0,10,10,60,24,"Test")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_MONITORPOWER, 2)
Delay(500)
SendMessage_(#HWND_BROADCAST, #WM_SYSCOMMAND, #SC_MONITORPOWER, -1)
EndSelect
EndSelect
Until Quit = 1
Re: Window goes to maximum after monitor turned off and on again
Posted: Wed Aug 27, 2025 4:14 pm
by Lord
Olli wrote: Wed Aug 27, 2025 12:16 pm
...
Could you test a softwared switch off ?
Yes, I did.
There was no problem. The window wasn't maximized.
I tried Rashads snipped above: no problem.
Also the 'normal' standby mode didn't any harm.
Only power off/on showed the problem.