Scaling issue - DPI aware activates itself and break layouts

Windows specific forum
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Scaling issue - DPI aware activates itself and break layouts

Post 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
地球上の平和
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

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

Post 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
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post by Saki »

Hi Demivec,
many thanks for testing, yes, the same.

Best regards Saki
地球上の平和
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

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

Post by gurj »

96 pixels / inch = 100% zoom.
120 pixels / inch =120/96= 125% zoom.
my pb for chinese:
http://ataorj.ys168.com
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post by Saki »

Hi Gurj
This is not the Problem, try the test codes

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

Best regards Saki
地球上の平和
fryquez
Enthusiast
Enthusiast
Posts: 369
Joined: Mon Dec 21, 2015 8:12 pm

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

Post 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.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
User avatar
Caronte3D
Addict
Addict
Posts: 1055
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

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

Post 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.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2071
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

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

Post 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
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
BarryG
Addict
Addict
Posts: 3324
Joined: Thu Apr 18, 2019 8:17 am

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

Post 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
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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 !
地球上の平和
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

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

Post 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!
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

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

Post 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
地球上の平和
Post Reply