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?