#PB_Compiler_DPIAWARE
#PB_Compiler_DPIAWARE
Can we have a #PB_Compiler_DPIAWARE reserved compiler constant please; similar to #PB_Compiler_Thread etc.
Thanks.
Thanks.
I may look like a mule, but I'm not a complete ass.
Re: #PB_Compiler_DPIAWARE
Maybe I'm missing it somewhere. Where is DPI-aware a compiler option in the IDE?
Re: #PB_Compiler_DPIAWARE
You're using the latest beta, right? It's in there. (I don't have it installed anymore, but I saw it when I had it).
Re: #PB_Compiler_DPIAWARE
Yes it is in the latest beta - Windows only.
I may look like a mule, but I'm not a complete ass.
Re: #PB_Compiler_DPIAWARE
Ahh, I see. I'm still using 5.61.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: #PB_Compiler_DPIAWARE
A quick workaround, before waiting two years for a constant:
Code: Select all
EnableExplicit
Procedure enumRes(hModule.i, type.i, name.i, *isDpiAware.BYTE)
Define.i hResInfo, hResData, resMem, resSize, xml
Define.i rootNode, dpiNode
Define.s nodeText
If name = 1
hresInfo = FindResource_(hModule, name, type)
hResData = LoadResource_(hModule, hResInfo)
resSize = SizeofResource_(hModule, hResInfo)
resMem = LockResource_(hResData)
xml = CatchXML(#PB_Any, resMem, resSize)
If XMLStatus(xml) = #PB_XML_Success
rootNode = RootXMLNode(xml)
dpiNode = XMLNodeFromPath(rootNode, "assembly/asmv3:application/asmv3:windowsSettings/dpiAware")
If dpiNode
nodeText = GetXMLNodeText(dpiNode)
If nodeText = "true"
*isDpiAware\b = #True
Else
*isDpiAware = #False
EndIf
Else
*isDpiAware = #False
EndIf
EndIf
FreeResource_(hResData)
ProcedureReturn #False ;stop
Else
ProcedureReturn #True ;continue
EndIf
EndProcedure
Define.b isDpiAware
EnumResourceNames_(#Null, #RT_MANIFEST, @enumRes(), @isDpiAware)
Debug isDpiAware
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: #PB_Compiler_DPIAWARE
Your code works fine here with PB 5.70 LTS on Windows 10, thank you!
A bit shorter:
A bit shorter:
Code: Select all
EnableExplicit
Prototype.i ProtoIsProcessDPIAware()
Procedure.i IsDPIAware()
Protected IsProcessDPIAware.ProtoIsProcessDPIAware
Protected.i user32, dpiaware=#False
user32 = OpenLibrary(#PB_Any, "user32.dll")
If user32
IsProcessDPIAware = GetFunction(user32, "IsProcessDPIAware")
If IsProcessDPIAware
dpiaware = IsProcessDPIAware()
EndIf
CloseLibrary(user32)
EndIf
ProcedureReturn dpiaware
EndProcedure
Debug IsDPIAware()
Re: #PB_Compiler_DPIAWARE
Your code does not work here on Win7 64, returns always true regardless of the dpi setting in compiler options.
A bit simpler version of my previous code without the enum callback:
A bit simpler version of my previous code without the enum callback:
Code: Select all
Procedure IsDpiAware()
Define.i hResInfo, hResData, resMem, resSize, xml, hModule
Define.i rootNode, dpiNode
Define.s nodeText
hModule = GetModuleHandle_(#Null)
hresInfo = FindResource_(hModule, 1, #RT_MANIFEST)
hResData = LoadResource_(hModule, hResInfo)
resSize = SizeofResource_(hModule, hResInfo)
resMem = LockResource_(hResData)
If resMem
xml = CatchXML(#PB_Any, resMem, resSize)
If xml And XMLStatus(xml) = #PB_XML_Success
rootNode = RootXMLNode(xml)
dpiNode = XMLNodeFromPath(rootNode, "assembly/asmv3:application/asmv3:windowsSettings/dpiAware")
If dpiNode
nodeText = GetXMLNodeText(dpiNode)
If nodeText = "true"
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
Else
ProcedureReturn #False
EndIf
FreeXML(xml)
EndIf
EndIf
If hResData : FreeResource_(hResData) : EndIf
ProcedureReturn #False
EndProcedure
Re: #PB_Compiler_DPIAWARE
Because "Use Windows XP Style DPI Scaling" is on by default (Win7)!Justin wrote:Your code does not work here on Win7 64, returns always true regardless of the dpi setting in compiler options.
Et cetera is my worst enemy
Re: #PB_Compiler_DPIAWARE
Why did #PB_Compiler_DpiAware get removed from the final of 5.70? It was there in the beta.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: #PB_Compiler_DPIAWARE
I see. Your new code works also as expected on Windows 10. Thank you!Justin wrote:Your code does not work here on Win7 64, returns always true regardless of the dpi setting in compiler options.
Re: #PB_Compiler_DPIAWARE
Must admit that I am simply using DesktopScaledX() etc, which even if running on a setup with anything other than 100% DPI scaling, still returns 1.0 if the DPIAware compiler option is not used. In this regards, no #PB_Compiler_DPIAWARE constant is actually required unless you want to remove the related desktop functions from your source via some conditional compilation in the case that DPIAware is not set.
Having said that, nice code Justin. Works well here, though of course it is not a compile time option. That nicely answers a question of mine which I hadn't gotten around to asking, namely does setting the DPIAware option actually set the 'dpiAware' app manifest option for use by Win 8.1 and Win 10? I can see it does now which is just as well as DPI virtualization would otherwise have caused a major problem.
Having said that, nice code Justin. Works well here, though of course it is not a compile time option. That nicely answers a question of mine which I hadn't gotten around to asking, namely does setting the DPIAware option actually set the 'dpiAware' app manifest option for use by Win 8.1 and Win 10? I can see it does now which is just as well as DPI virtualization would otherwise have caused a major problem.
I may look like a mule, but I'm not a complete ass.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: #PB_Compiler_DPIAWARE
For me personally, a #PB_Compiler_DPIAWARE constant would be useful for checking whether or not I had forgotten to choose the respective compiler option for that code.srod wrote:Must admit that I am simply using DesktopScaledX() etc, which even if running on a setup with anything other than 100% DPI scaling, still returns 1.0 if the DPIAware compiler option is not used. In this regards, no #PB_Compiler_DPIAWARE constant is actually required unless you want to remove the related desktop functions from your source via some conditional compilation in the case that DPIAware is not set.
Also, using such a constant would make the code more self documenting. This is especially important when exchanging code here on the forum, so that other users just can copy, paste and run it. Otherwise, the person who posts the code would have to write a concerning remark, which can easily be forgotten.
That said, the person who writes the code can do without the constant #PB_Compiler_DPIAWARE (deliberately or not), even when it does exist.
So for optimal self-documentation of the code, I really would appreciate it if DPI awareness (and other things as well) could be switched on and off ONLY be using a respective constant in the code.