It is currently Thu Nov 21, 2019 2:07 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 1:57 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 687
Location: Canada
Does anyone know of a way to detect whether PB 5.70 DPi flag is checked ?

It's easily done with
Code:
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.

_________________
"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: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 3:08 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 629
Location: Linz, Austria
https://www.purebasic.fr/english/viewtopic.php?p=532057#p532057
https://www.purebasic.fr/german/viewtopic.php?p=351249#p351249


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 3:17 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 687
Location: Canada
@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.

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


Last edited by Blue on Fri Mar 22, 2019 4:53 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 3:33 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3458
Hi Blue
From German forum
Code:
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

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 4:27 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 687
Location: Canada
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.

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


Last edited by Blue on Tue Aug 27, 2019 1:26 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 1:21 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 629
Location: Linz, Austria
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...


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 3:12 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3458
Using Windows API
No workaround
Code:
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

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 4:12 pm 
Online
Enthusiast
Enthusiast

Joined: Tue May 26, 2009 2:11 pm
Posts: 617
RASHAD wrote:
Using Windows API
No workaround
Code:
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

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 4:29 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3458
Works here as expected
PB 5.70 x64
Windows 7 Ultimate x64

Quote:
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

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 5:07 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13628
Location: France
I will add a compiler constant to detected this easily.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 5:35 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 629
Location: Linz, Austria
Even better... thx


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Fri Mar 22, 2019 6:01 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3458
Thanks Fred
According to MSDN IsProcessDPIAware() is not accurate and even GetProcessDpiAwareness() do not work properly (tested with Win 7 & Win 8.1)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect whether PB 5.70 DPi flag is checked
PostPosted: Tue Aug 27, 2019 2:48 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Oct 06, 2006 4:41 am
Posts: 687
Location: Canada
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 ??

_________________
"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: Detect whether PB 5.70 DPi flag is checked
PostPosted: Thu Aug 29, 2019 4:32 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13628
Location: France
Just forgotten. Moved to feature request.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: Lord and 6 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