alank2 5 Posted August 2, 2023 I have them set to (left, top, width, height) 45, 80, 500, 320 in the form designer. I also have borderstyle=none, position=designed, but at runtime if I evaluate them they are 45, 80, 516, 358 so the width and height were altered by something. I remember a thing called scale for VCL, but I don't see it present in the FMX form. Any ideas why the width/height changed? Can I prevent it without forcing the width/height in the form constructor (which does work)? Share this post Link to post
Martifan 5 Posted August 2, 2023 When dealing with FireMonkey (FMX) applications, you should remember that FMX uses a different rendering model than the VCL. In FMX, all coordinates are floating point and device-independent, and the coordinate system's origin is at the top left of the form, with positive Y coordinates going downwards. Moreover, the dimensions of the form include the non-client area (like the title bar and borders) of the form. When you set the BorderStyle property to None, you're telling FireMonkey not to include a non-client area. Therefore, FireMonkey reduces the Width and Height values to compensate for the removed non-client area. To keep the client area of the form the same, regardless of whether a non-client area is included, you need to adjust the Width and Height properties when the BorderStyle property changes. This can be done in the OnCreate event of the form. Here's an example: procedure TForm1.FormCreate(Sender: TObject); var NonClientRect: TRectF; begin BorderStyle := TFmxFormBorderStyle.None; NonClientRect := GetClientRect; // Get the client rect before changing the border style // Adjust the size Width := Width + (Width - NonClientRect.Width); Height := Height + (Height - NonClientRect.Height); end; In this code, we first get the current client rectangle before changing the border style to None. We then adjust the Width and Height of the form based on the difference between the form's original size and the client rectangle's size. This way, when you change the border style to None, the size of the client area remains the same. However, please note that you need to adjust this code if you have other components on your form that might change the size of the client area. Share this post Link to post