Home > Enterprise >  How to adjust visual components that don't scale correctly in a high DPI aware Windows applicat
How to adjust visual components that don't scale correctly in a high DPI aware Windows applicat

Time:01-25

In a previous question I managed to adjust the "padding" between components using Monitor.PixelsPerInch.

Now I have a different problem: I have a "..." (browse) TButton at the left of a TEdit (path). At design time both VCL components have the same height in their Height property and visually. At runtime under a 4K monitor (scaling of 120%) the components are scaled differently and the TButton have like 3 pixels more at the bottom vs the TEdit which gives an inconsistent GUI.

How can I adjust the height after the automatic (magic) scaling happened? I'm still using Delphi 10.4.

CodePudding user response:

Button1.Height:=Edit1.Height;
Button1.Top:=Edit1.Top;

in either FormCreate, FormActivate or FormResize.

(provided they are both children of the same parent)

CodePudding user response:

Use TRelativePanel as a container of both TEdit and TButton. Set TButton properties AlignTopWith, AlignBottomWith, RightOf to the TEdit instance. Also set AlignWithMargins to True and adjust the Margins

  •  Tags:  
  • Related