Autor Beitrag
mexx
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Do 01.12.05 09:12 
Hi,

ich habe ein Pupup dessen Item zur Laufzeit erstellt werden. Nun muss ich aber die Items auswählen und die Caption selktieren.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
 for i := 0 to ListBox1.Count - 1 do
  begin
   eintrag := ListBox1.Items.Strings[i];
   PopUpMenu1.Items.Add(NewItem(Eintrag, i, false, true, MenuClick, 0, ''));

  end;


Damit lese ich die Einträge der Listbox aus und trage sie in das Popup ein. Funktioniertt auch. Aber wie bekomme ich jetzt beim Clicken auf den Eintrag den Name herraus?

Gruß mexx
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 01.12.05 09:40 
Moin

Probier das mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  i: Integer;
begin
  for i := 0 to ListBox1.Count - 1 do
    PopUpMenu1.Items.Add(NewItem(ListBox1.Items.Strings[i], i, false, true, MenuClick, 0, ''));
end;

procedure TForm1.MenuClick(Sender: TObject);
begin
  ShowMessage((Sender as TMenuItem).Caption);
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Do 01.12.05 09:44 
Ich erhalte eine Zugriffsverletzung, wenn auf das Item klicke.
mexx Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1183



BeitragVerfasst: Do 01.12.05 10:10 
Upps, habe was entscheidendes vergessen.
Die Variable MenuClick muss global deklariert sein.