Skip to content

Make a control DPI aware unmanaged

António Lopes edited this page Mar 3, 2021 · 2 revisions

Make a control DPI-aware unmanaged

In the same way that a VFP application tells Windows that it will handle the rendering of its forms in a High DPI monitor, by declaring itself to be DPI-aware, controls at any point of the control hierarchy may tell the DPI-aware manager that they won't be managed.

Usually, the need for unmanaged controls comes either to respect some graphic object's aspect and integrity or because the control is already being subject to any management.

For instance, the dimension of a ChartCanvas image control of a FoxChart container is controlled by its parent. If the DPI-aware manager steps in, its action will collide with the intervention of the canvas controller, and, as a result, it will mislead the image over its size.

When a FoxChart object in a form is moved from a High DPI scale to a lower or regular scale, it will think that it will have a smaller canvas:

(in a High DPI 150% monitor)

FoxChart @ 150%

(then back to a regular 100% monitor)

FoxChart back @ 100%

As part of resizing procedures, the canvas will redraw correctly when its size is managed only by its parent. To make sure that the manager does not interfere, in the Init() method of the canvas image the following code will protect it from the intervention of the DPI-aware manager:

This.AddProperty("DPIAware", .F.)
DODEFAULT()

From now on, whenever the DPI-aware manager inspects the canvas, it will acknowledge that it must not process it.

FoxChart @ 100%, unmanaged

Note: if an unmanaged control is a container, the manager will also disregard all of the contained controls and objects.

Clone this wiki locally