It is currently Tue Jan 26, 2021 6:06 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Problem With ResizeWindow and DPI Aware
PostPosted: Tue Sep 01, 2020 5:32 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 1032
Location: Canada
In Windows 10 set your screen scaling to 125% or 150% and run this code with "DPI aware" turned on.
If I move the Main Window the others will stay locked with it. Now uncomment the "flag" line and run it again.
Now when I move the Main Window the others slowly wander off the screen. ?!?!?

(I only see this behavior when "DPI Aware" is on and the #PB_Window_SizeGadget flag is used)

Code:
#Main=0
Global Dim w(3),x,y

Procedure Move()
  fixx=WindowX(#Main)-x
  fixy=WindowY(#Main)-y
  x=WindowX(#Main)
  y=WindowY(#Main)
  For tmp=0 To 3
    ResizeWindow(w(tmp),WindowX(w(tmp))+fixx,WindowY(w(tmp))+fixy,#PB_Ignore,#PB_Ignore)
  Next
EndProcedure


;flag=#PB_Window_SizeGadget  ;<------- test this line

If OpenWindow(#Main,0,0,900,300,"Main",#PB_Window_SystemMenu)
  For tmp=0 To 3
    w(tmp)=OpenWindow(#PB_Any,10+pos,50,200,150,"Win"+Str(tmp),flag,WindowID(Main))
    pos+210
  Next

  BindEvent(#PB_Event_MoveWindow,@Move(),#Main)
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Thu Sep 03, 2020 1:44 pm 
Offline
User
User

Joined: Wed Jun 07, 2017 10:13 pm
Posts: 19
Hello Paul,
I found your topic because I am having dpi troubles too.
I found out that also the ResizeGadget() is not working correctly IF two screens (monitors) have different DPI setting.

ResizeGadget() works correct if screen1 dpi = 100% and screen2 dpi = 100%
ResizeGadget() works correct if screen1 dpi = 125% and screen2 dpi = 125%
ResizeGadget() works correct if screen1 dpi = 150% and screen2 dpi = 150%

ResizeGadget() works NOT correct if screen1 dpi = 100% and screen2 dpi = 125%
ResizeGadget() works NOT correct if screen1 dpi = 1250% and screen2 dpi = 100%
etc...

So there is definitly something wrong with the dpi awareness, your code is proof
Just tested your code and indead the child windows wander off !!!

It is even worse when you use

fixx=WindowX(#Main,#PB_Window_InnerCoordinate)-x
fixy=WindowY(#Main,#PB_Window_InnerCoordinate)-y


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Wed Sep 09, 2020 11:11 am 
Offline
User
User

Joined: Wed Jun 07, 2017 10:13 pm
Posts: 19
Fixed

Code:
#Main=0
Global Dim w(3),x,y

Procedure Move()
  fixx=WindowX(#Main)-x
  fixy=WindowY(#Main)-y
  x=WindowX(#Main)
  y=WindowY(#Main)
  For tmp=0 To 3
    ResizeWindow(w(tmp),(WindowX(w(tmp))+fixx)/DesktopResolutionX(),WindowY(w(tmp))+fixy,#PB_Ignore,#PB_Ignore)
  Next
EndProcedure


;flag=#PB_Window_SizeGadget  ;<------- test this line

If OpenWindow(#Main,0,0,900,300,"Main",#PB_Window_SystemMenu)
  For tmp=0 To 3
    w(tmp)=OpenWindow(#PB_Any,10+pos,50,200,150,"Win"+Str(tmp),flag,WindowID(Main))
    pos+210
  Next

  BindEvent(#PB_Event_MoveWindow,@Move(),#Main)
  Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Wed Sep 09, 2020 2:26 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 1032
Location: Canada
williamvanhoecke wrote:
Fixed


I'm guessing you either don't have "DPI Aware" enabled in compiler settings or you don't have Windows scaling set over 100% because your code shoots the Forms off the screen even faster than the original code when its compiled as "DPI Aware" ;)

Anyway I'm not looking for a bandaid I'm looking for it to be fixed internally.
If I want a bandaid I can just remove the resize flag on the Form, use the resize command then add the resize flag back every time an adjustment needs to be made.

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Sun Sep 13, 2020 7:39 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 725
Location: Canada
Problem confirmed, exactly as pointed out.

Nice find, Paul.

And since — to my knowledge anyway — you can't turn ON/OFF DPi awareness on the fly, the PB_Window_SizeGadget option remains unusable until the underlying bug is corrected.

_________________
"That's not a bug..." said the programmer. "...It's a feature! "
"Oh! I see..." replied the blind man.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Mon Sep 14, 2020 8:49 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
Fixed.


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Wed Nov 25, 2020 5:23 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:34 pm
Posts: 1032
Location: Canada
Fred wrote:
Fixed.


Just tested with PureBasic 5.73 LTS x64

Unfortunately this is only fixed on Windows 10.
If I run the above code on Windows 8 and Windows 7 at 150% Scaling, DPI Aware Enabled and #PB_Window_SizeGadget enabled, all the child windows head off the screen to the right.

_________________
Image Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Problem With ResizeWindow and DPI Aware
PostPosted: Wed Nov 25, 2020 11:12 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14181
Location: France
I only tested on Win10, I will take a closer look again


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye