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.

Delphi 7 & Windows scaling.

Post Reply
PhillHS
Posts: 6
Joined: Sun Mar 05, 2023 5:27 pm

Delphi 7 & Windows scaling.

Post by PhillHS »

Hi all,

I'm using Delphi 7 on Windows 10 X64.

I have a 4K monitor, which I have set to a 150% scaling in windows display settings.

Having now integrated CEF4 Delphi into my app I find that it now seems to be ignoring the scaling and running at the native resolution (and screwing up the placement of some of my other components). Is there any way to prevent this.

This also seems to affect the SimpleBrowser2 demo (see attached screenshots).

At design time, scaling works.....
Screenshot 2023-03-06 205512.png
At runtime it doesn't
Screenshot 2023-03-06 205638.png
Cheers.

Phill.
You do not have the required permissions to view the files attached to this post.
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Delphi 7 & Windows scaling.

Post by dilfich »

Code: Select all

GlobalCEFApp.AddCustomCommandLine('--force-device-scale-factor', '1');
Is it possible?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Delphi 7 & Windows scaling.

Post by salvadordf »

Hi,

Try the command line switch that dilfich gave you in the previous post and read this :
https://github.com/salvadordf/CEF4Delphi/issues/449
Student
Posts: 72
Joined: Tue Aug 07, 2018 9:20 am

Re: Delphi 7 & Windows scaling.

Post by Student »

Yes, I noticed it a couple of months ago that since version 108 forced HiDPI.
Who doesn't need HiDPI, you can try to forcibly disable it this way, before call GlobalCEFApp.StartMainProcess

Code: Select all

SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
PhillHS
Posts: 6
Joined: Sun Mar 05, 2023 5:27 pm

Re: Delphi 7 & Windows scaling.

Post by PhillHS »

Concatinating replies :
dilfich wrote: Tue Mar 07, 2023 7:14 am

Code: Select all

GlobalCEFApp.AddCustomCommandLine('--force-device-scale-factor', '1');
Is it possible?
I tried that and it didn't seem to work :(
Student wrote: Tue Mar 07, 2023 9:59 am Yes, I noticed it a couple of months ago that since version 108 forced HiDPI.
Who doesn't need HiDPI, you can try to forcibly disable it this way, before call GlobalCEFApp.StartMainProcess

Code: Select all

SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE);
Delphi 7 doesn't seem to have imports for those functions as they where introduced with more recent versions of windows.....
However I guess I should be able to import them from the correct DLL and give it a try.

What I have found does work is setting the properties for my exe in windows explorer :-
Right click->compatibility tab->Change HiDPI settings button

Then check "overide high dpi scaling behavior" and set it to system in the dropdown.

What supprised me is that it retained those settings when I re-compiled the exe.

Cheers.

Phill.
Post Reply