Page 1 of 1
Added :DPI Scale for Windows XP,Vista,7,8 & 10 [Windows]
Posted: Sun Nov 05, 2017 8:25 pm
by RASHAD
Hi
Very Simple
Tested but not too much
Code: Select all
If OSVersion() >= #PB_OS_Windows_7 And OSVersion() < #PB_OS_Windows_8
Global ScaleX.d = GetDeviceCaps_(GetDC_(0),#LOGPIXELSX) / 96
Global ScaleY.d = GetDeviceCaps_(GetDC_(0),#LOGPIXELSY) / 96
Debug ScaleX.d
Debug ScaleY.d
ElseIf OSVersion() >= #PB_OS_Windows_8
ExamineDesktops()
h.WINDOWPLACEMENT
GetWindowPlacement_(GetDesktopWindow_(),@h)
Global ScaleX.d = DesktopWidth(0) / h\rcNormalPosition\right
Global ScaleY.d = DesktopHeight(0) / h\rcNormalPosition\bottom
Debug ScaleX.d
Debug ScaleY.d
EndIf
Re: DPI Scale for Windows 7,8 & 10 [Windows]
Posted: Sun Nov 05, 2017 10:23 pm
by MarkOtt
Hello RASHAD
According to my experience this cannot work for general. The GUI elements have to be scaled everytime, but not the fonts. Depending on the choosen Windows scaling settings sometimes the fonts have to be scaled, sometimes not.
Pleas see my post:
http://www.purebasic.fr/english/viewtop ... 12&t=69570
Best regards. Markus
Edit (to clarify a little bit):
Using PB up to version 5.24 the fonts were scaled automatically correct without scaling them in the program. It was just enough to scale the other GUI elements.
Using PB version 5.45 (and 5.61) the things got more complicated:
Eg. in Windows 10, if I set 125% in the "fixed scaling dialog" (where I can choose 100%, 125%, 150%) then the fonts are not scaled automaticall by Windows, so I have to also scale the fonts in my program.
But Windows 10 scales the fonts automatically correct if I set 125% in the "user scaling dialog" (where it is possible to scale continuously). So Windows 10 font scaling is not behaving consistently, it depends on how it is set by the user. This is what my approach seems to solve (and it works also for Win 7 and 8 ).
Re: DPI Scale for Windows 7,8 & 10 [Windows]
Posted: Mon Nov 06, 2017 6:47 am
by RASHAD
Next is an optimized version
No need to check which MS OS version are used
The aim of this post is the Scale nothing less nothing more
Is the scale all right or not
The Fonts are the coder responsibility
He/She should use his own font and do not rely on MS defaults
Code: Select all
Global ScaleX1.d,ScaleY1.d,ScaleX2.d,ScaleY2.d,ScaleX.d,ScaleY.d
ScaleX1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSX) / 96
ScaleY1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSY) / 96
ExamineDesktops()
h.WINDOWPLACEMENT
GetWindowPlacement_(GetDesktopWindow_(),@h)
ScaleX2 = DesktopWidth(0) / h\rcNormalPosition\right
ScaleY2 = DesktopHeight(0) / h\rcNormalPosition\bottom
If ScaleX1 > ScaleX2
ScaleX = ScaleX1
Else
ScaleX = ScaleX2
EndIf
If ScaleY1 > ScaleY2
ScaleY = ScaleY1
Else
ScaleY = ScaleY2
EndIf
Debug ScaleX
Debug ScaleY
Re: Added :DPI Scale for Windows XP,Vista,7,8 & 10 [Windows]
Posted: Tue Nov 07, 2017 7:54 am
by RASHAD
Added XP & Vista
Code: Select all
Global ScaleX1.d,ScaleY1.d,ScaleX2.d,ScaleY2.d,ScaleX.d,ScaleY.d
ScaleX1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSX) / 96
ScaleY1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSY) / 96
ExamineDesktops()
h.WINDOWPLACEMENT
GetWindowPlacement_(GetDesktopWindow_(),@h)
ScaleX2 = DesktopWidth(0) / h\rcNormalPosition\right
ScaleY2 = DesktopHeight(0) / h\rcNormalPosition\bottom
If ScaleX1 > ScaleX2
ScaleX = ScaleX1
Else
ScaleX = ScaleX2
EndIf
If ScaleY1 > ScaleY2
ScaleY = ScaleY1
Else
ScaleY = ScaleY2
EndIf
If OSVersion() < #PB_OS_Windows_Vista
ScaleX = ScaleX1
ScaleY = ScaleY1
EndIf
Debug ScaleX
Debug ScaleY
Re: Added :DPI Scale for Windows XP,Vista,7,8 & 10 [Windows]
Posted: Mon Jan 08, 2018 6:57 pm
by Rothammel
RASHAD wrote:Added XP & Vista
Code: Select all
Global ScaleX1.d,ScaleY1.d,ScaleX2.d,ScaleY2.d,ScaleX.d,ScaleY.d
ScaleX1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSX) / 96
ScaleY1 = GetDeviceCaps_(GetDC_(0),#LOGPIXELSY) / 96
ExamineDesktops()
h.WINDOWPLACEMENT
GetWindowPlacement_(GetDesktopWindow_(),@h)
ScaleX2 = DesktopWidth(0) / h\rcNormalPosition\right
ScaleY2 = DesktopHeight(0) / h\rcNormalPosition\bottom
If ScaleX1 > ScaleX2
ScaleX = ScaleX1
Else
ScaleX = ScaleX2
EndIf
If ScaleY1 > ScaleY2
ScaleY = ScaleY1
Else
ScaleY = ScaleY2
EndIf
If OSVersion() < #PB_OS_Windows_Vista
ScaleX = ScaleX1
ScaleY = ScaleY1
EndIf
Debug ScaleX
Debug ScaleY
when I use this code with dpi aware statement in my executable manifest, it will not work. it gives every time 1.0 back