Informatik Material Portal Portfolio Präsentation Grafik Tabellenkalkulation Informatik56 9 10 11 12 13 Messen, Steuern, Regeln Linux Theorie Didaktik Open Source Spiele Wettbewerbe Netzbetreuung intern Literatur Links Energie corewar UNIX/Linux
Pfad: Startseite / Fächer / Informatik
Autor: be
21.09.2005 10:52
476

Runtime-Schaltfläche

Die Schaltfläche Button1 wird wie üblich in das Formular gesetzt

Die Schaltfläche Button2 wird während des Programmablaufs (on runtime) erzeugt.

unit mRuntimeButton;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
    Button2: TButton;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Color := RGB(Random(256),Random(256),Random(256))
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Button2 := TButton.Create(Form1);
  with Button2 do
  begin
    Parent := Form1;
    Top := 80;
    Left := Button1.Left;
    Caption := 'Button2';
    onClick := Button1Click;
  end;
end;

end.