Form ratio scaling lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2025-08-25 08:19 Hello, I have a question: is it possible to implement proportional scaling of a form, e.g. 16:9, but without unnecessary flickering of the form so that it scales nicely and smoothly? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i private     FIgnoreResize: Boolean;   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject);begin  Width := 854;   Height := 480;   DoubleBuffered := True;   FIgnoreResize := False;end; procedure TForm1.FormResize(Sender: TObject);constRatio: Double = 16 / 9;varNewHeight: Integer;beginif FIgnoreResize then Exit; FIgnoreResize := True;try   NewHeight := Round(Width / Ratio);  if NewHeight <> Height then    Height := NewHeight;finally  FIgnoreResize := False;end;end; ---------------------------------------------------------------------- Ally · 2025-08-25 10:35 Hello Pe3s, I have reduced the whole thing to the bare minimum. The window changes size without flickering. (Win11, Lazarus 4.2) ---------------------------------------------------------------------- Pe3s · 2025-08-25 14:01 The code works, but you just need to add it to OnResize Form and change the size, then it's a disco. ---------------------------------------------------------------------- Ally · 2025-08-25 14:32 That's not a problem for me on Windows either. Your code also runs without flickering. However, the problem could be the following: FormResize is called when the size of Form changes. If you change the size of Form within FormResize, FormResize is called again. That doesn't normally make sense. That's why I put the size change of Form in a ButtonClick to prevent the recursive call. ---------------------------------------------------------------------- Ally · 2025-08-25 15:56 I must apologize. I have now understood the problem. Enclosed is a solution that prevents flickering when changing the size. ---------------------------------------------------------------------- Pe3s · 2025-09-07 09:40 The code maintains proportions, but if we want to maximize the application, a problem arises. Is it possible to implement code logic that would maintain proportions when resizing the form and allow the form to be maximized without flickering? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormResize(Sender: TObject);var  NewHeight: Integer;begin  NewHeight := Round(Width / (16 / 9));  Constraints.MaxHeight := NewHeight;  Constraints.MinHeight := NewHeight;end;