Beware of TForm.SetBounds in a multi-monitor context

When in a multi-monitor context with monitors having varying DPI settings, TForm.SetBounds can be a little ambiguous when combined with form scaling.

The issue comes from Width / Height, in Delphi 10.3.1, they are understood as applying to the monitor the form is currently one, not the monitor SetBounds could be moving the form to. This is manifest when restoring a form position: if you store a form’s bounds, then try to restore it with SetBounds, it will result in an incorrectly sized form.

The workaround is trivial however: move the form first, then resize it, which comes down to

form.SetBounds(placement.Left, placement.Top, form.Width, form.Height);
form.SetBounds(dest.placement, placement.Top, placement.Width, placement.Height);

so two calls instead of one.