Autor Beitrag
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Do 28.11.02 22:00 
ich möchte eine history-liste (aus einer ini) in ein popupmenü einbinden. wenn der user auf ein item klickt soll in einem edit feld ein bestimmter pfad erscheinen.

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Do 28.11.02 23:23 
Ein Beispiel:

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
    procedure Pop1Popup(Sender: TObject);
    procedure MyPopupHandler(Sender: TObject);
  public
    { Public-Deklarationen }
  end;

...

procedure TForm1.Pop1Popup(Sender: TObject);
var
  i: Integer;
  PopItem: TMenuItem;
begin
  with PopupMenu1 do for i := 0 to Items.Count - 1 do Items.Delete(0);

  for i := 0 to 10 do begin
    PopItem := TMenuItem.Create(Self);
    with PopItem do begin
      Caption := IntToStr(i);
      OnClick := MyPopupHandler;
      PopupMenu1.Items.Add(PopItem);
    end;
  end;
end;

procedure TForm1.MyPopupHandler(Sender: TObject);
begin
  with Sender as TMenuItem do begin
    ShowMessage( Caption );
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Pop1Popup(Sender);
  Self.PopupMenu := PopupMenu1;
end;