Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
Re: Menüs zur Laufzeit ok, aber wie anwählen?
30. Apr 2004, 19:23
Delphi-Quellcode:
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
Button1: TButton;
mnuFile: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure MyMenuItemOnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyMenuItemOnClick(Sender: TObject);
begin
case (Sender as TMenuItem).Tag of
0: ShowMessage((Sender as TMenuItem).Caption);
1: ShowMessage((Sender as TMenuItem).Caption);
2: ShowMessage((Sender as TMenuItem).Caption);
3: ShowMessage((Sender as TMenuItem).Caption);
4: ShowMessage((Sender as TMenuItem).Caption);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
NewItem: TMenuItem;
i: Integer;
begin
for i := 0 to 4 do
begin
NewItem := TMenuItem.Create(Form1);
NewItem.Caption := IntToStr(i);
NewItem.Tag := i;
NewItem.OnClick := MyMenuItemOnClick;
mnuFile.Add(NewItem);
end;
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|