Hi,
Zitat von
Luckie:
Soll das so was werden:
Delphi-Quellcode:
type
TForm1 = class(TForm)
Button1: TButton;
PopupMenu1: TPopupMenu;
procedure Button1Click(Sender: TObject);
procedure PopupItemClick(Sender: TObject);
private
{ Private declarations }
ItemCount: Cardinal;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PopupItemClick(Sender: TObject);
begin
case (Sender as TMenuItem).Tag of
1: ShowMessage(IntToStr((Sender as TMenuItem).Tag));
2: ShowMessage(IntToStr((Sender as TMenuItem).Tag));
else
ShowMessage('foo');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Item: TMenuItem;
begin
Inc(ItemCount);
Item := TMenuItem.Create(PopupMenu1);
Item.Caption := IntToStr(ItemCount);
Item.Tag := ItemCount;
Item.OnClick := PopupItemClick;
PopupMenu1.Items.Add(Item);
end;
Genau!
Ach Mensch! Stimmt! Ich muss jedem Item die Eventbehandlung einzeln zuweisen!
Danke Leute!