Search code examples
delphidelphi-10.4-sydneyhighdpi

How to adjust visual components that don't scale correctly in a high DPI aware Windows application made in Delphi?


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.


Solution

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

    in either FormCreate, FormActivate or FormResize.

    (provided they are both children of the same parent)