I'm trying to use the overloaded function of SetBounds()
in FMX.Forms
, passing Screen.Displays[index].BoundsRect
as a parameter. However, since Delphi 11 BoundsRect
seems to return a TRectF
rather than TRect
.
I'm looking for a way to convert this TRectF
to a TRect
so that I can pass it to SetBounds()
.
@SilverWarior's answer (and @AndreasRejbrand's comment to it) explains how to convert TRectF
to TRect
so you can use it with the TForm.SetBounds()
method (or TForm.Bounds
property).
I just want to mention that, along with the TDisplay.BoundsRect
change from TRect
to TRectF
, Delphi 11 also introduced a new TForm.SetBoundsF()
method, and a new TForm.BoundsF
property, both of which take floating point coordinates via TRectF
instead of integer coordinates via TRect
.
So, you don't need to convert the coordinates from floating points to integers at all. You just need to update your code logic to call a different method/property instead, eg:
Pre-D11:
MyForm.Bounds := Screen.Displays[index].BoundsRect;
or
MyForm.SetBounds(Screen.Displays[index].BoundsRect);
Post-D11:
MyForm.BoundsF := Screen.Displays[index].BoundsRect;
or
MyForm.SetBoundsF(Screen.Displays[index].BoundsRect);