Page 1 of 2
Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 1:57 am
by Blue
Does anyone know of a way to detect whether
PB 5.70 DPi flag is checked ?
It's easily done with
Code: Select all
is_dpiFlag_set.i = Bool(DesktopResolutionX() > 1)
Debug is_dpiFlag_set
; or
is_dpiFlag_set = Bool(DesktopScaledX(100) > 100)
Debug is_dpiFlag_set
when running on a system with a high DPi monitor setting , but that method will always yield
False on a system with a regular dpi setting.
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 3:08 am
by chi
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 3:17 am
by Blue
@chi : please READ the question again.
I’m not looking for a way to check if the app is dpi aware.
I’m asking if there is a way to programmatically figure out whether the PB 5.70 dpi checkbox is checked.
Sometimes, later... :
I see that you've added a new link to your answer. The code in that one appears to be spot on.
Thank you very much, @chi, for going to the trouble of locating that piece of code on the German Forum. It does exactly what I was looking for.
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 3:33 am
by RASHAD
Hi Blue
From German forum
Code: Select all
CompilerIf #PB_Compiler_OS=#PB_OS_Windows
CompilerIf #PB_Compiler_Version>=570
Define DPIFlag.l
EnableASM
MOV eax,dword [PB_Compiler_DPIAware]
MOV DPIFlag,eax
If 0 = DPIFlag
MessageRequester("Info","Compiler Option DPIAware Not checked.")
Else
MessageRequester("Info","Compiler Option DPIAware checked.")
EndIf
CompilerElse
CompilerError "PureBasic 5.70 Or higher version is needed."
CompilerEndIf
CompilerEndIf
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 4:27 am
by Blue
Thank you, RASHAD.
In the absence of a compiler-style constant (à la #PB_Compiler_something), your code will do.
Let's see now if it works...
10 minutes later...
Perfect ! Exactly what I wanted.
Rashad : If you know the author of this piece of code, transmit my appreciation to him/her/it.
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 1:21 pm
by chi
Blue wrote:@chi : please READ the question again.
I’m not looking for a way to check if the app is dpi aware.
I’m asking if there is a way to programmatically figure out whether the PB 5.70 dpi checkbox is checked.
Sometimes, later... :
I see that you've added a new link to your answer. The code in that one appears to be spot on.
Thank you very much, @chi, for going to the trouble of locating that piece of code on the German Forum. It does exactly what I was looking for.
The day after... : You're too fast, man! I posted the second link within a few seconds

. Anyway, glad it worked out for you...
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 3:12 pm
by RASHAD
Using Windows API
No workaround
Code: Select all
CompilerIf #PB_Compiler_OS=#PB_OS_Windows
CompilerIf #PB_Compiler_Version >= 570
Lib = OpenLibrary(#PB_Any, "user32.dll")
If Lib
Result = CallFunction(Lib, "IsProcessDPIAware")
CloseLibrary(Lib)
EndIf
If Result
MessageRequester("Info","Compiler Option DPIAware checked.")
Else
MessageRequester("Info","Compiler Option DPIAware Not checked.")
EndIf
CompilerElse
CompilerError "PureBasic 5.70 Or higher version is needed."
CompilerEndIf
CompilerEndIf
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 4:12 pm
by Lord
RASHAD wrote:Using Windows API
No workaround
Code: Select all
CompilerIf #PB_Compiler_OS=#PB_OS_Windows
CompilerIf #PB_Compiler_Version >= 570
Lib = OpenLibrary(#PB_Any, "user32.dll")
If Lib
Result = CallFunction(Lib, "IsProcessDPIAware")
CloseLibrary(Lib)
EndIf
If Result
MessageRequester("Info","Compiler Option DPIAware checked.")
Else
MessageRequester("Info","Compiler Option DPIAware Not checked.")
EndIf
CompilerElse
CompilerError "PureBasic 5.70 Or higher version is needed."
CompilerEndIf
CompilerEndIf
This gives here:"Compiler Option DPIAware checked." but it is not checked in compiler options.
PB 5.70LTs(x64) on Win7 Ultimate SP 1 x64
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 4:29 pm
by RASHAD
Works here as expected
PB 5.70 x64
Windows 7 Ultimate x64
MSDN
Return Value
Type: Type: BOOL
TRUE if the process is dpi aware; otherwise, FALSE.
Requirements
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 5:07 pm
by Fred
I will add a compiler constant to detected this easily.
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 5:35 pm
by chi
Even better... thx
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 22, 2019 6:01 pm
by RASHAD
Thanks Fred
According to MSDN IsProcessDPIAware() is not accurate and even GetProcessDpiAwareness() do not work properly (tested with Win 7 & Win 8.1)
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Tue Aug 27, 2019 2:48 pm
by Blue
Fred wrote:I will add a compiler constant to detected this easily.
PB 5.71 LTS has been released... and I don't see any such constant in it.
So is it hidden ? or simply forgotten ??
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Thu Aug 29, 2019 4:32 pm
by Fred
Just forgotten. Moved to feature request.
Re: Detect whether PB 5.70 DPi flag is checked
Posted: Fri Mar 06, 2020 8:35 pm
by Andre
It would be very good to get such a (compiler) function with the current PB updates.
It's needed to be able to react on the current DPI-aware setting, e.g. with image sizes and their display...