The previous release PowerBuilder 2025 already supports high DPI (static DPI). When an application starts at a fixed DPI scale, controls and fonts are rendered clearly at the correct size.
This release supports dynamic DPI awareness, enabling your applications to automatically adjust when moved between monitors with different DPI settings or when the system DPI changes at runtime. This includes new functions for detecting and responding to DPI changes, ensuring consistent layout and font rendering across high-DPI environments.
-
Dynamic DPI
When the DPI scale changes while the application is running, the application automatically adjusts the size and layout of windows, controls, and fonts to match the new DPI.
First, enable DPI scaling by calling
Application.SetHighDpiMode(4)in the Application Open event before opening any windows, especially if the application is upgraded from an earlier version, the default DPI mode will beNone(0), you will need to explicitly set the mode toPerMonitorV2(4).Secondly, implement dynamic DPI scaling through the following event and function:
-
DPIChanged event -- Use this window event to handle DPI change notifications at runtime, so you can adjust layouts, fonts, or graphics immediately when the system DPI changes. Note that this event will be fired only when the application is compiled and run as an executable file.
-
GetDpiForWindow function -- Use this function to query the current DPI for a window or control and implement DPI-aware custom drawing or layout adjustments. This is especially useful when mixing standard PowerBuilder controls with manual rendering logic.
-
-
Known issues or differences
-
The measurement unit Pixel used in scripts may not calculate properly.
If you use pixel values in the application, note that pixel values will change significantly at high DPI because it will use the real monitor pixel in PerMonitorV2.
Solution: This issue can be resolved by taking advantage of the
GetDpiForWindowfunction and multiplying the original calculation by a "scaling factor" to adapt to different DPIs. For example:Dec lde_scale = 1.0 Int li_width_pixel // Get the scaling rate for the current window. lde_scale = GetDpiForWindow(This)/96 // If the display scaling setting is 150% in a 4K monitor, you will get 1.5. li_width_pixel = 100*lde_scale // If you want to draw a 100px visual yourself, you may now need to draw more pixels on a high DPI display.
-
When working in the current IDE (without DPI support), control sizes may change by 1 pixel after saving or reading them. This is normal behavior caused by internal size conversions.
-
UI or controls rendered by Windows APIs or UI frameworks may not support dynamic DPI.
UI elements or controls (such as TX Text control, InkPicture control) that are rendered by the Windows APIs or third-party UI frameworks may not scale or refresh properly when the DPI changes.
-
The FontSize property returns the original point size and does not change with DPI (font size will be scaled during display).
-
Proportional scaling of non-TrueType fonts is not supported.
If controls use non-TrueType fonts, the fonts and controls may not scale in the same ratio, causing visual discrepancies (e.g., text may not fully display within controls).
Solution: Most fonts are TrueType, but some legacy projects may use non-TrueType fonts. Changing to TrueType font can bypass this issue.
-
For more information, refer to the section called “Enabling DPI Awareness”.


