0

I'm developing applications on a Windows 7 system using Embarcadero RAD Studio C++ Builder XE7. I'm trying to make one of my application DPI aware. To achieve that, I need to reproduce one of the following behavior:

  • Stop all type of DPI awareness and let the application on the same size, whatever DPI is chosen
  • Allow Windows to virtualize the application (AFAIK this is the default behavior)
  • Notify Windows that application is DPI aware, and let the application resizes its components, by enabling the TForm Scaled property on every forms of my app.

Using a manifest file, I can perfectly reproduce these 3 scenarios on my application.

However I want to select the way the application will behave from inside the application itself, on runtime. For example, I want to use a command line like the following to open my application:

C:> MyApp.exe /DPIBehavior=[Ignored, Virtualized, Scaled]

I noticed that the Windows SDK provides several functions to achieve that. As I'm still developing on Windows 7, I cannot use nor test the SetProcessDPIAwareness() function, because unavailable before Windows 8.1, so I tried to use the SetProcessDPIAware() function.

I noticed that this function stops well the Windows virtualization process. However my form is no longer scaled, even if the Scaled property is set to true on my form properties. I specify here that I compiled 2 different versions of my app, one with the Scaled property enabled on the main forn, the other without, but the both with a call to the SetProcessDPIAware() function as soon as possible.

I tested these application versions under 192 dpi. As they produce the exact same result, i.e. an user interface of the exact same size, I deduce that the scaling isn't working when the SetProcessDPIAware() function is used. On the other hand, when I run the exact same apps using a manifest instead of a call to the SetProcessDPIAware() function, I obtain the expected result: one app is scaled, the other not.

Can anyone explain to me how to use the SetProcessDPIAware() function while keeping the TForm scaling? Or is it a XE7 bug?

Jean-Milost Reymond
  • 1,833
  • 1
  • 15
  • 36
  • I will try to reply later tonight. – selbie Oct 30 '18 at 22:11
  • @selbie Thank you – Jean-Milost Reymond Oct 30 '18 at 22:37
  • https://stackoverflow.com/questions/8296784/how-do-i-make-my-gui-behave-well-when-windows-font-scaling-is-greater-than-100 – Hans Passant Oct 30 '18 at 23:35
  • @HansPassant Thanks for your reply, but this is not a solution for the question I asked. My question is: "why the Windows API SetProcessDPIAware() function stops the effect of the Scaled property on my forms", and not "why my application is scaled and how should I make it DPI aware". As I said above, I haven't issue with the interface itself, and the manner it deals with high DPI when I modify the manifest is good for me. However I want to do exactly the same thing on runtime, with the Windows API, but the behavior I obtain differs from what I expected. And I want to know why. – Jean-Milost Reymond Oct 31 '18 at 13:36
  • I know what you're asking, and know why you are not getting an answer. That Q+A I linked shows you how to do it right, you can use it to document your question better. Focusing on how you did it wrong. – Hans Passant Oct 31 '18 at 14:30
  • @HansPassant Ok, I will re-read. Thank you for the answer. – Jean-Milost Reymond Oct 31 '18 at 15:52

0 Answers0