Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

High DPI solution for the Delphi 7 applications which includes embed Chromium (DCEF)

Post Reply
User avatar
DimKas
Posts: 1
Joined: Sat Dec 19, 2020 2:26 pm

High DPI solution for the Delphi 7 applications which includes embed Chromium (DCEF)

Post by DimKas »

The Delphi7 applications can looks good in 4k monitors. The Windows 10 can help them. They're use 'DPI awareness' plus 'GDI scaling'. But if the application contains a component of the Chromium DCEF3 (or DCEF4 not matter), then collision occurs. Because to looks good the Chromium(DCEF) not need in 'GDI scaling' and 'DPI awareness'.

The simple way to switch the DPI apps by manifest file. For my app MShop.exe I've added the file MShop.exe.manifest:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <assemblyIdentity
        version="1.0.0.0"
        processorArchitecture="X86"
        name="Melbis Shop"
        type="win32"
    />
    <asmv3:application>
            <asmv3:windowsSettings>
                <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> 
                <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> 
                <gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
            </asmv3:windowsSettings>
        </asmv3:application>

    <description>Melbis Shop e-commerce</description>
    <dependency> 
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="x86"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
    </dependency>
   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
   </trustInfo>
</assembly>
In this case I've good scaling for application (large icons and control's text), but with bad(not need) scaling for HTML-editor (DCEF3 component's):
scr1-1.png
If I use another way to NO to 'DPI awareness' in the file MShop.exe.manifest (only changed lines):

Code: Select all

<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> 
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">system</dpiAwareness> 
In this case I've no(bad) scaling for application (small icons and control's text), but with no(good) scaling for HTML-editor (DCEF3 component's):
scr2-1.png

May be, a possible way is to add the second manifest file for the Chromium component which placed in file libcef.dll?
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: High DPI solution for the Delphi 7 applications which includes embed Chromium (DCEF)

Post by salvadordf »

Hi,

If you use a browser in normal mode then you can try adding this before the GlobalCEFApp.StartMainProcess call in the DPR file :

Code: Select all

GlobalCEFApp.AddCustomCommandLine('--force-device-scale-factor', '1');
The scale factor is calculated using this formula : scale = screen_DPI / 96
Try using different values instead of 1, for example 1.5 for a screen with a 150% scale.

If you use a browser in OSR mode then you can simulate any screen scale. See the WebpageSnapshot demo to know how to set a custom screen scale :
https://github.com/salvadordf/CEF4Delph ... ad.pas#L55
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: High DPI solution for the Delphi 7 applications which includes embed Chromium (DCEF)

Post by salvadordf »

I just edited the previous message with the right switch --force-device-scale-factor

I'll upload a new CEF4Delphi version with a new GlobalCEFApp property to handle this more easily.
User avatar
salvadordf
Posts: 4052
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: High DPI solution for the Delphi 7 applications which includes embed Chromium (DCEF)

Post by salvadordf »

Please download CEF4Delphi from GitHub again and try the new GlobalCEFApp.ForcedDeviceScaleFactor property.
Post Reply