salvadordf / CEF4Delphi

CEF4Delphi is an open source project to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows, Linux and MacOS.
https://www.briskbard.com/forum/
Other
1.2k stars 365 forks source link

Problems with screen resolution in windows after updating component in delphi 2010 #449

Closed speedti closed 1 year ago

speedti commented 1 year ago

Hello Salvador.

After updating the CEF4 package in version 109.0.5414.120 in delphi 2010, my systems lose resolution if the user changes the display scale on the monitor to 125 or 150%. This problem doesn't happen if I use OldCEF4. I did a test with the latest version available for download and the same problem occurs. With Delphi Alexandria this problem does not happen, only with Delphi 2010. Is there any way to resolve this?

Thanks. bug - BUG normal - OK

salvadordf commented 1 year ago

Hi,

New Chromium versions seem to detect the monitor scale and calls SetProcessDPIAware.

I don't have a Delphi 2010 license but I wouldn't be surprised that it had issues handling high DPI monitor settings. The best solution would be to build your application in the latest Delphi version.

If you can't use a newer Delphi version then the easiest solution to this issue would be to launch your application from a Windows shortcut that has disabled the high DPI setting. https://superuser.com/questions/1100491/what-does-disable-display-scaling-on-high-dpi-settings-on-windows-10-mean

If everything else fails then I would try to insert an application manifest to your executable. I haven't tried this solution but the Windows SDK has a "mt.exe" utility for this purpose : https://stackoverflow.com/questions/1423492/how-do-i-add-a-manifest-to-an-executable-using-mt-exe

Read these documents for more information : https://docwiki.embarcadero.com/RADStudio/Sydney/en/Customizing_the_Windows_Application_Manifest_File https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process https://learn.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows

salvadordf commented 1 year ago

This seems to be the CEF issue related to this problem : https://bitbucket.org/chromiumembedded/cef/issues/3452/cef-sets-windows-process-dpi-awareness-if

salvadordf commented 1 year ago

High-DPI support is now enabled by default in Chromium.

salvadordf commented 1 year ago

I'll copy some of the suggested workarounds for this issue. https://www.briskbard.com/forum/viewtopic.php?f=8&t=2121

Dilfich's suggestion : Add this line before the GlobalCEFApp.StarMainProcess call in the DPR file : GlobalCEFApp.ForcedDeviceScaleFactor := 1;

Student's suggestion : Add these calls : SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE); SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);