Function and property

The DPI scaling mode will work only when the application is compiled as an executable file and run in Windows 10 (version 1703) or later and Windows Server 2016 or later.

The DPI scaling mode must be set before any window is opened.

The mode can be set either in the IDE painter or in the scripts. Once the mode is set successfully to any value other than 0 (None) (in the IDE or in the scripts), it cannot be changed in the script any more.

  • In the IDE painter

    Open the application object painter, go to the application's Properties view, select a value from the HighDpiMode property listbox. The value can be one of the following: 0 - None, 1 - DpiUnaware, 2 - SystemAwareness, 3 - PerMonitor, 4 - PerMonitorV2 (Default), and 5 - DpiUnawareGdiScaled.

    The HighDPIMode property can only be set in the IDE. It cannot be set in the script; but you can get its property value in the script.

  • In the scripts

    The Application SetHighDPIMode function must be called before any window is opened (for example, it can be called in the Application's Open event). Once the mode is set successfully to any value between 1 and 5 (inclusive); the subsequent SetHighDPIMode function calls will fail and return -1.

Note

For all desktop applications (including PowerBuilder applications), the DPI scaling mode can be set in several ways and will take effect in the following order: application executable property (①) > manifest file (②) > Windows API (③).

The PowerBuilder HighDPIMode property and SetHighDPIMode function call the Windows API (③) to set the awareness mode, therefore please notice the following:

1) If the mode is set successfully in the application executable property (①) or manifest file (②), the PowerBuilder HighDPIMode property and SetHighDPIMode function will not take effect.

2) The Windows API (to be specific, SetProcessDpiAwarenessContext) (③) will work only in Windows 10 (version 1703) or later and Windows Server 2016 or later; in the other Windows OS, no mode will be set (the application will run in the None(0) mode).