[SOLVED] Components AutoSizing on Notebook lazarus / 31-LCL ---------------------------------------------------------------------- d3crypti0n · 2021-04-22 22:04 I found an interesting code snippet on the internet that adjusts all the components to the size of the tool. So when you stretch/shrink the tool, the components get bigger/smaller and the distance to each other and the edge of my form always stays equivalent to the size of my tool. If you shrink the window to a minimum no component disappears from the window. The font size changes as well. Now when I add a Notebook with different pages, the components of my tool stay fixed. When you shrink the tool and move the side of the window, the components don't get bigger/smaller and they are also not accessible if you don't move the side back. I hope it get's clear what I mean How would you change the code in order for the components to be stretched/shrunken on a Notebook-Page ? 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 unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,  ExtCtrls, Buttons, Menus; type   { TForm1 }   TForm1 = class(TForm)    Notebook1: TNotebook;    PaintBox1: TPaintBox;     PaintBox2: TPaintBox;    Button1: TButton;    Button2: TBUtton;    Page1: TPage;    Page2: TPage;     procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);    procedure FormResize(Sender: TObject);   private   public   end; var  Form1: TForm1;  AutoZoom: array of array of real;  FormAspect: real; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin   Close;end; procedure TForm1.FormCreate(Sender: TObject);var  i: Integer;begin   FormAspect := Self.Width / Self.Height;   SetLength(AutoZoom, Self.ControlCount, 6);   for i := 0 to Self.ControlCount - 1 do   begin      AutoZoom[i][0] := Self.Controls[i].Top / Self.Height;      AutoZoom[i][1] := Self.Controls[i].Left / Self.Width;      AutoZoom[i][2] := Self.Controls[i].Width / Self.Width;      AutoZoom[i][3] := Self.Controls[i].Height / Self.Height;      if Self.Controls[i].Font.Height = 0 then         Self.Controls[i].Font.Height := 80;  //Font.Size         AutoZoom[i][4] := Self.Controls[i].Font.Height / Self.Width;         AutoZoom[i][5] := Self.Controls[i].Font.Height / Self.Height;   end;end; procedure TForm1.FormResize(Sender: TObject);var   i: integer;begin   for i := 0 to Form1.ControlCount - 1 do      begin       Self.Controls[i].Top := Round(AutoZoom[i][0] * Self.Height);       Self.Controls[i].Left := Round(AutoZoom[i][1] * Self.Width);         Self.Controls[i].Width := Round(AutoZoom[i][2] * Self.Width);         Self.Controls[i].Height := Round(AutoZoom[i][3] * Self.Height);       if Self.Width / Self.Height < FormAspect then            Self.Controls[i].Font.Height := Round(AutoZoom[i][4] * Self.Width)       else            Self.Controls[i].Font.Height := Round(AutoZoom[i][4] * Self.Height);      end;end; end. ---------------------------------------------------------------------- jamie · 2021-04-22 23:47 Have you met Mr. Anchor Editor ? Other than that, you may need to adjust your font sizes.. ---------------------------------------------------------------------- alpine · 2021-04-22 23:49 Quote from: d3crypti0n on April 23, 2021, 12:04:22 amNow when I add a Notebook with different pages, the components of my tool stay fixed. When you shrink the tool and move the side of the window, the components don't get bigger/smaller and they are also not accessible if you don't move the side back. I hope it get's clear what I mean That is because Form1.Controls doesn't include them. There is only the Notebook1 on which the Form1 is the immediate owner. Notebook1.Controls eventually includes Page1 and Page2. In turn, each of the pages includes some of the other controls. You can't walk them in a single loop, you should go in depth. Quote from: d3crypti0n on April 23, 2021, 12:04:22 amHow would you change the code in order for the components to be stretched/shrunken on a Notebook-Page ? May be you should consider the Anchors property and Anchor Editor into the Object Inspector if you want to keep the edge offsets constant. IMHO, (if we put aside the question of the rightness of this method) this code is incorrect for scaling, at least it keeps a lot of unnecessary information. You can keep only the X,Y ratios of the form itself.