unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus;
type
TForm1 =
class(TForm)
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure MeineProzedur(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MeineProzedur(Sender: TObject);
begin
Label1.Caption := (Sender
as TMenuItem).Caption;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
test: TMenuItem;
begin
test := TMenuItem.Create(self);
//Erstelle MenuItem
test.Caption := '
Test';
test.OnClick := MeineProzedur;
MainMenu1.Items[0].Add(test);
//Füge Item ein, 0 steht für das erste Elternelement des Menüs
end;
end.