[Lazarus] Hi-DPI tweak of components

Ondrej Pokorny lazarus at kluug.net
Thu Jun 8 07:53:28 CEST 2023


On 08.06.2023 00:46, Vojtěch Čihák via lazarus wrote:
>
> Thanks,
>
> please confirm me if I understand well the concept:
>
> 1) when component is put on the form in designer: it is scaled (Width 
> & Height)
>
Yes.

> 2) when it is put on the form later in code: it is not scaled
>
It depends on what you understand with "it is not scaled".

If you do:

MyComponent.Parent := Panel1;
MyComponent.Width := 100;
MyComponent.Height := 100;

Then obviously the width/height is not scaled because you assigned 
constant numbers there.

But the internals are scaled with DoAutoAdjustLayout() if the target PPI 
(of Panel1) is different from Screen.PixelsPerInch.


> but internals are scaled in both cases (by internals I mean for 
> example DefaultRowHeight and DefaultColWidth of TStringGrid)
>
> Or at least TStringGrid behaves as I described above.
>
Yes.


> Because I need to scale internals of TGraphicControl (which has no own 
> Canvas or Handle) I decided to do scaling in SetParent();.
>
You definitely should use DoAutoAdjustLayout().


> For curiosity: was tested the case when someone has two or more 
> monitors with different DPI and moves the form (made in Lazarus) from 
> one monitor to another?
>
Yes. DoAutoAdjustLayout() takes care of it.

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20230608/7049a2f1/attachment-0001.htm>


More information about the lazarus mailing list