Page 1 of 2

Scaling issue - DPI aware activates itself and break layouts

Posted: Thu May 21, 2020 9:23 am
by Saki
Hello, everyone,
it may not be that easy to and it took me a long time to crystallize it exactly.
So I've decided to post it here again because it's a very bad mistake.
Unfortunately I can't tell if it is a bug of the OS or PB.
But it is already more than helpful to know that he exists and what he does,
because it is almost impossible to find and locate him.

In Windows there are the extended scaling,
that is, where you can enlarge the desktop.
These are not those that are fixed, but those that have to be typed in by hand.
If a user uses this possibility, because the default of 125% is too crisp for him, he will get 120%, for example, if there are problems.
These problems only occur when the magnification is entered manually and they seem to occur at magnifications >100% to 125%.
Whether it also occurs at further magnifications must be tested, especially 120% is very bad, because this is often used.
It was very difficult to see what happens and why, because you don't know the context and only see the effect.

If such a scaling is chosen, the process is always DPI aware, even if it is disabled in the PB Compiler options.
This leads to layout corruption of different outputs, which a user or developer can almost not localize.
The functions for determining the scaling always return 100%, although it is e.g. 125%.

viewtopic.php?f=27&t=75348

Please check this once

Best regards Saki

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Fri May 22, 2020 3:27 pm
by Saki
Here a other test code

Code: Select all

Define wID=OpenWindow(#PB_Any, 0, 0, 610, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Define font=LoadFont(#PB_Any , "Arial" , 26 , #PB_Font_Bold)

StartDrawing(WindowOutput(wID))
DrawText(0 , 10 , "Try scaling 125% with and without DPI aware Compiler option")
DrawText(0 , 30 , "First try the 125% that Windows offers directly in the scaling menu")
DrawText(0 , 50 , "Then switch to the extended scales and enter the 125% by hand again !")
DrawText(0 , 80 , "Compare the results and you will see the bug")

DrawingFont(FontID(font))
DrawText(0 , 120 , "You ever must see this line complete")
StopDrawing()

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 10:04 am
by Demivec
Do you get the same problem with this small change?

Code: Select all

Define wID=OpenWindow(#PB_Any, 0, 0, 610, 400, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

Define font=LoadFont(#PB_Any , "Arial" , DesktopUnscaledY(26) , #PB_Font_Bold)

StartDrawing(WindowOutput(wID))
DrawText(0 , 10 , "Try scaling 125% with and without DPI aware Compiler option")
DrawText(0 , 30 , "First try the 125% that Windows offers directly in the scaling menu")
DrawText(0 , 50 , "Then switch to the extended scales and enter the 125% by hand again !")
DrawText(0 , 80 , "Compare the results and you will see the bug")

DrawingFont(FontID(font))
DrawText(0 , 120 , "You ever must see this line complete")
StopDrawing()

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 10:09 am
by Saki
Hi Demivec,
many thanks for testing, yes, the same.

Best regards Saki

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 11:38 am
by gurj
96 pixels / inch = 100% zoom.
120 pixels / inch =120/96= 125% zoom.

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 12:05 pm
by Saki
Hi Gurj
This is not the Problem, try the test codes

这不是问题,请尝试测试代码

Best regards Saki

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 12:24 pm
by fryquez
That's a Windows behavior for unaware applications.
If you want correctly scaling enable DPI option.

Anyway, this is not a PB bug.

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 1:06 pm
by Saki
Hi fryquez
It's not right what you write.
Please read firstly the thread and try the demo codes.

It is not about whether it is a PB or a Windows bug.
It's about the fact that it's a buggy behavior that causes massive problems and is very hard to localize.

And you as a PB and Windows user are directly affected.
It destroys the layouts of the users of your programs !

The name of this sub-forum ist Bugs - Windows, not PB-Bugs - Windows,
so it is the right place for this posts :wink:

Best regards Saki

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Wed May 27, 2020 3:54 pm
by Caronte3D
The problem with the different DPIs on Windows is ever a headache The true is we don't have on PB a simple method to get the same interface on different DPIs :cry:

I test my code every time on different monitors on different DPIs an almost ever I need to adjust manually something.

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Fri May 29, 2020 8:05 pm
by Saki
Hi Caronte3D

I hate that DPI aware stuff,
he makes simple things complicated.
Switching older complex graphics software to DPI aware is more than an adventure,
it's annoying and you're tempted to throw everything out the window.

It should be up to the OS to provide high quality output, not up to the programmer.

Best regards Saki

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Sat May 30, 2020 8:34 pm
by Andre
While I'm trying to adapt my project to be DPI-aware I have tested the example codes above and can confirm that there is something buggy with a 'manually set DPI scaling factor of 125%'.

While with 125% choosen in the related combobox in Windows settings (DPI-aware on + off) the text always is shown completely, with manually entered 125% and 'DPI-aware off' in the PB compiler settings the text doesn't fit into the window (see screenshot below).

Would be good, if Fred can take a look into the library code of the Desktop library, if there is something wrong or if we encountered a bug in the used WinAPI commands (workaround possible?)... Thank you :D

Image

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Sun May 31, 2020 2:32 am
by BarryG
Saki wrote:The name of this sub-forum ist Bugs - Windows, not PB-Bugs - Windows,
so it is the right place for this posts :wink:
No, this sub-forum is for bugs in the Windows version of PureBasic. Not for Windows itself.

Image

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Sun May 31, 2020 8:57 am
by Saki
Andre wrote: Would be good, if Fred can take a look into the library code of the Desktop library, if there is something wrong or if we encountered a bug in the used WinAPI
@BarryG
It would be very helpful if you could explain the cause of the bug and how to get rid of it !

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Sun May 31, 2020 10:29 am
by helpy
Probably it is not only a PureBasic problem.

Have you done a research on this topic at microsoft.com?
==> https://support.microsoft.com/en-us/hel ... pi-devices

More information at blog.windows.com:
==> https://blogs.windows.com/windowsdevelo ... ktop-apps/

It is an very complex topic!

Re: Scaling Bug - DPI aware activates itself and break layou

Posted: Sun May 31, 2020 11:12 am
by Saki
Hi helpy,
many thanks.
Your postings are ever good and helpfull

Please look for this detail
Andre wrote: While with 125% choosen in the related combobox in Windows settings (DPI-aware on + off) the text always is shown completely, with manually entered 125% and 'DPI-aware off' in the PB compiler settings the text doesn't fit into the window (see screenshot below).
Use we the combobox, all is OK, both should work at the same
Only the manually set scales >100% to 125% are affected
From 126% upwards it works properly again

Best regards Saki