1 Attachment(s)
VB6 Preventing Display Scalilng (DPI Aware) Not Working
greetings,
i have a package/app/tool developed in vb6 that's need run/open without scaling in case running windows has enabled widows dpi scaling like 125% or 150%.
so, after some google search i have found that i need to embed a manifest in my exe file and set "dpiAware" to true?!?. so, i tried that but still same :(
here is the screenshot how it looks like if the display is with 125% scaling..
Attachment 187146
here the black/blue border area is the actual app/window area. and the red area is used/scaled by windows when display is 125%. (i set app form back color to red).
and here is the manifest part where i used dpiAware:
Code:
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
i even tried to set dpiAware to "false", but same outcome..
so, it looks like manifest is not the solution here? or i missing something/part?
thanks in advance
best regards
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Do you want your package/app/tool to be exactly X pixels in width on a 4K monitor so the form appears the size of a post-stamp on screen or you want your package/app/tool to be legible on screen but within it all coordinates to remain like no scaling is happening?
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Not sure if the syntax difference matters but it normally looks like
Code:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Your app also needs to be themed and the manifest saved as "yourappname.exe.manifest". Here's a working manifest:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" version="1.00.0.0" processorArchitecture="x86" name="YourAppName"/>
<description>YourAppDescription</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" version="6.0.0.0" processorArchitecture="x86" name="Microsoft.Windows.Common-Controls" language="*" publicKeyToken="6595b64144ccf1df"/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
You need to compile the manifest into a ".RES" file with ID 24 (using RC.exe and a ".RC" file):
"yourappname.rc" template for compiling the manifest:
Code:
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define RT_MANIFEST 24
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "yourappname.exe.manifest"
Compile the manifest into a resource file with:
Code:
"C:\Program Files (x86)\Microsoft Visual Studio\VB98\Wizards\RC.EXE" /r /fo yourappname.res yourappname.rc
Then add the "yourappname.res" file into your VB project and compile a new executable. You should be all set now!
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Much easier ways to do this...
LaVolpe's Manifest Creator II
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Is it working or is it not working, that's the question.
In other words, why do you say it is not working.
Run this code to check whether it is working or not:
Code:
MsgBox Screen.TwipsPerPixelX
If you run the compiled exe to other than 100%/96 DPI and it reports 15, then the manifest is not working.
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
You can't be DPI Aware simply by marking your compiled program as such. It works where twips/pixel is an integer but fails in cases where it isn't. There are workarounds to do most of the scaling yourself but that can add up to a lot of fiddly code in a program with a complex user interface.
Here you seem to be trying to say "don't scale anything for me automatically" but that fails to take into account other scaling in a VB UI that assumes integral twips/pixel, points/pixel, etc.
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
I assumed he used an embedded manifest.
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Quote:
Originally Posted by
fafalone
I know that thread, I've contributed to it! :D The thing is, once you already have a working manifest and just need some minor tweaks to it then it's easier to edit it in Notepad and then run a ".BAT" file to compile it...
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
You can just include the manifest via the Registry Editor add-in too. No need for RC.exe for this.
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
I think you mean the "Visual Basic 6 Resource Editor" add-in, I don't have any Registry Editor add-in. As far as I can tell the RC.exe tool is adding some binary data to the manifest when compiling it to a ".RES" file. I don't think the add-in can do that and furthermore I think this extra data is also required to make the ".RES" file aligned to a dword boundary... After compiling it then you can add it to your project with the add-in or simply by right-clicking on the project and selecting "Add File".
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Yes, my mistake. I was trying to do two things at once and "registry" got typed in error.
You can do the DWORD padding manually. Just create your file, check the size, then add spaces at the end to a 4-byte boundary.
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Quote:
Originally Posted by
VanGoghGaming
Your app also needs to be themed and the manifest saved as "yourappname.exe.manifest". Here's a working manifest:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">......</assembly>
You need to compile the manifest into a ".RES" file with ID 24 (using RC.exe and a ".RC" file):
....
You should be all set now!
update: i have added your manifest, but outcome is same (as the attached screenshot in main post)
Quote:
Originally Posted by
Eduardo-
Is it working or is it not working, that's the question.
In other words, why do you say it is not working.
Run this code to check whether it is working or not:
Code:
MsgBox Screen.TwipsPerPixelX
If you run the compiled exe to other than 100%/96 DPI and it reports 15, then the manifest is not working.
update: on 125% display settings it shows 12
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Quote:
Originally Posted by
Shohag_ifas
update: on 125% display settings it shows 12
Then the manifest is working. The problem is then the interpretation of how to handle DPI awareness.
Maybe this can help: DPI, DPI setting, Twips and DPI awareness
Re: VB6 Preventing Display Scalilng (DPI Aware) Not Working
Try testing it at 200%. That's an example of where it all breaks down. It should give 7.5 but you get 7 (wrong) instead.
Being properly DPI aware is a lot of work and a good deal of stuff VB6 relies on truncates scaling to integer values like that.