Answers for "PAS = Easy Button Multiple to 10"

0

PAS = Easy Button Multiple to 10

procedure TForm1.FormCreate(Sender: TObject);
var
  i:       Integer;
  aButton: TButton;
begin
  for i := 0 to 9 do begin                // create 10 Buttons 
    aButton := TButton.Create(Self);      // create Button, Owner is Form1, where the button is released later
    aButton.Parent  := Self;              // determine where it is to be displayed
    aButton.Width   := aButton.Height;    // Width should correspond to the height of the buttons
    aButton.Left    := i * aButton.Width; // Distance from left
    aButton.Caption := IntToStr(i);       // Captions of the buttons (0.9)
    aButton.OnClick := @aButtonClick;     // the event handler for the button -> will be created yet
  end;
  Self.Height := aButton.Height;          // Height of the form should correspond to the height of the buttons
  Self.Width  := aButton.Width * 10;      // Width of the form to match the width of all buttons
end;
Posted by: Guest on July-22-2021

Browse Popular Code Answers by Language