Window goes to maximum after monitor turned off and on again

Just starting out? Need help? Post your questions and find answers here.
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Window goes to maximum after monitor turned off and on again

Post 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.
Image
Olli
Addict
Addict
Posts: 1238
Joined: Wed May 27, 2020 12:26 pm

Re: Window goes to maximum after monitor turned off and on again

Post by Olli »

Can you clarify how you turn the screen off and on again?
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Window goes to maximum after monitor turned off and on again

Post by Lord »

Using the monitors power switch.
Image
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Window goes to maximum after monitor turned off and on again

Post 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.
Image Image
TassyJim
Enthusiast
Enthusiast
Posts: 186
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Window goes to maximum after monitor turned off and on again

Post 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
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Window goes to maximum after monitor turned off and on again

Post 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?
Image
TassyJim
Enthusiast
Enthusiast
Posts: 186
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Window goes to maximum after monitor turned off and on again

Post 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
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Window goes to maximum after monitor turned off and on again

Post 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.
Image
Olli
Addict
Addict
Posts: 1238
Joined: Wed May 27, 2020 12:26 pm

Re: Window goes to maximum after monitor turned off and on again

Post by Olli »

Lord wrote: Mon Aug 25, 2025 9:59 pm Using the monitors power switch.
Could you test a softwared switch off ?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4953
Joined: Sun Apr 12, 2009 6:27 am

Re: Window goes to maximum after monitor turned off and on again

Post 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
Egypt my love
User avatar
Lord
Addict
Addict
Posts: 907
Joined: Tue May 26, 2009 2:11 pm

Re: Window goes to maximum after monitor turned off and on again

Post 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.
Image
Post Reply