Autor Beitrag
orakel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Mi 22.10.03 18:20 
Hi,
Ich habe folgendes Problem:
Beim Klicken von einem Button soll ein Memofeld erstellt werden. Und beim anklicken dieses Memofeldes (OnClick) soll dann z.B. eine Message erscheinen. Diese OnClick-Methode kann ich ja nicht im Objekt-Inspektor zuweisen (da es das Memo am Anfang ja noch nicht gibt), sondern muss das über den Quelltext.
Kann mir jemand da helfen?
:?:

_________________
Nicht verzagen, orakel fragen!
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 22.10.03 18:50 
Wenn du dein Memo dynamisch erstellt hast, kannst du ihm
einfach ein OnClick-Handler zuweisen:

ausblenden Delphi-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:
type 
  TForm1 = class(TForm) 
    {...} 
    private 
      DeinMemo : TMemo; 
      // OnClick handler für's Memo.
      procedure MemoClickHandler(Sender: TObject); 
  end; 

var 
  Form1: TForm1; 

implementation 

{$R *.DFM} 


procedure TForm1.MemoClickHandler(Sender: TObject); 
begin 
  ShowMessage(TMemo(Sender).Name); 
end; 

procedure TForm1.FormCreate(Sender: TObject); 
begin 
  DeinMemo := TMemo.Create(Self); 
  DeinMemo.Parent := Self;
  DeinMemo.OnClick := ButtonClickHandler;
end;
Shark
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Mi 22.10.03 18:55 
mit toms Vorschlag, aber ohne viel Tipperei:

ziehe Dir ein Memo aufs Form
onClick Ereignis(Procedure) erzeugen
Memo löschen
Procedure wie bei toms zuweisen
fertig

geht mit allen andern Ereignissen genauso und hast automatisch die richtigen Parameter
orakel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 92

Win XP

BeitragVerfasst: Do 23.10.03 11:54 
Danke, hat geklappt!! :lol:

_________________
Nicht verzagen, orakel fragen!