Autor Beitrag
patmann2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Fr 04.10.02 21:39 
Hallo
Wie kann ich bei einem zur Laufzeit erzeugten Menüeintrag das OnClick Ereigniss abfragen?

cu Patmann
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Fr 04.10.02 23:32 
Hallo,

du musst ihm einfach ein Behandlungsrutine zuweisen.

diese ist ein einfaches tNotifyEvent, wird also so deklariert:
ausblenden Quelltext
1:
procedure MeinMenuClick(Sender: TObject);					

Diese kannst du entweder direckt beim Erzeugen des Menüs hizufügen, z.B. so:
ausblenden Quelltext
1:
NewMenu := NewItem('Bezeichnung', 0, FALSE, TRUE, MeinMenuClick, 0, 'Untermenu' + IntToStr(i));					

oder im Nachhinein so;
ausblenden Quelltext
1:
NewMenu.OnClick := MeinMenuClick;					


Gruß
Klabautermann
patmann2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Sa 05.10.02 07:06 
Also
Ich habe n neue Menüeintrage. Wenn der User auf einen Menüeintrag klickt soll dieser Checked = True erhalten. Ausserdem brauche ich dann noch die Position des Items zurück.
Wie mache ich das am Besten. Die Delphi Hilfe hilft bei diesem Problem nicht wirklich weiter
cu Patmann
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 05.10.02 08:06 
In der Behandlungsroutine von Klabautermann ("MeinMenuClick") genannt, hast du über den "Sender" Zugriff auf menütypische Funktionen:
ausblenden Quelltext
1:
2:
3:
4:
procedure TForm1.MeinMenuClick(Sender: TObject);
begin
  (Sender as TMenuItem).Checked := true;
end;

usw.
patmann2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 201

Windows 7 Prof.
Delphi XE2
BeitragVerfasst: Sa 05.10.02 08:43 
Es klappt!
Danke an Alle
8)
cu Patmann
Beutel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89

WIN XP

BeitragVerfasst: Mi 02.03.05 15:25 
Und wie würde das bei einer Function aussehen? weil da bekomme ich es nett so hin wie es solte.