Registriert seit: 12. Aug 2003
Ort: Soest
4.016 Beiträge
Delphi 10.1 Berlin Enterprise
|
Re: Problem beim Zuweisen einer Procedure (Menüs)
20. Okt 2004, 12:58
Hi,
so müsste es funzen:
Delphi-Quellcode:
TForm1 = class(TForm)
{...}
private
ProgList: TStrings;
procedure MyOnClick(Sender: TObject);
end;
procedure FindProgramm(List: TStrings; AObject: TObject);
var
i: Integer;
begin
for i := 0 to Pred(List.Count) do
if List.Objects[i] = AObject then
begin
Result := List[i];
Break;
end;
end;
procedure TForm1.MyOnClick(Sender: TObject);
var
ProgName
begin
ProgName := FindProgramm(ProgList, Sender);
if ProgName <> '' then
RunProgramm(String);
end;
procedure TForm1.Button1Click(Sender: TObject);
var m: TMenuItem;
i: integer;
begin
for i := 1 to 10 do begin
m := TMenuItem.Create(PopupMenu1.Items[0]);
m.Caption := 'SubItem' + inttostr(i);
m.Name := 'Name' + inttostr(i);
m.OnClick := MyOnClick;
ProgList.AddObject(C:\...', m);
item1.Add(m);
end;
|