Autor Beitrag
Master_BB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: Sa 07.02.04 02:57 
hya,
ich wollte mal fragen ob ich OnCreate Ereignisse oder sonstige so unterbringen kann das ich die Form die variables erstellt wurde nicht global deklariert werden muß.
Als Bsp mal das hier
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Procedure TForm2.FormatAddBox;
var FormatBoxForm:TForm;
    FLabel:TLabel;
    FEdit:TEdit;
    OKButton,CancelButton:TButton;
    filename:string;
    DS:formatT;
Begin
 FormatBoxForm:=TForm.create(form2);
 with formatBoxForm do begin
   Width := 300;
   Height:= 100;
   Left  :=Trunc((Screen.Width-Width)/2);
   Top   :=Trunc((Screen.Height-Height)/2);
   Caption := 'Format hinzufügen';
   BorderStyle := bsSingle;
 end;

so jetzt will ich als OnCreate ereignis bei der FormatBoxForm auf eine procedure zugreifen. aber wenn ich das will muß ich die Form global deklarieren. Gibt es eine methode wie ich es gleich darein programmieren kann??

Greetz
Master_BB
TomT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 116

Suse 9.1 WinXP
D6 Pers
BeitragVerfasst: So 08.02.04 09:56 
So geht das:
ausblenden Delphi-Quelltext
1:
  OnCreate :=   Ereignis;					


Wobei Ereignis eine Prozedur sein muss, die einen TObject Parameter erhält. So in etwa:

ausblenden Delphi-Quelltext
1:
procedure Ereignis(sender : Tobject)					

_________________
...und da wurde mir klar, dass eine Toolbar keine Kneipe für Heimwerker ist.
Master_BB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: So 08.02.04 12:02 
ja bei dieser lösung ist nur das problem das man wenn man bei der ereignis procedur ein ergebnis der procedur in irgenteinem Label oder so ausgeben will dieses objekt global deklarieren muß.
und das will ich halt nicht
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 09.02.04 09:52 
Master_BB hat folgendes geschrieben:
ja bei dieser lösung ist nur das problem das man wenn man bei der ereignis procedur ein ergebnis der procedur in irgenteinem Label oder so ausgeben will dieses objekt global deklarieren muß.

Das habe ich jetzt nicht verstanden. Erklär dein Problem doch noch mal etwas genauer. Vielleicht auch mit einem Beispiel.

Gruß
Tino
Master_BB Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 90



BeitragVerfasst: Mo 09.02.04 19:44 
also
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Procedure TForm2.FormatAddBox; 
var FormatBoxForm:TForm; 
    FLabel:TLabel; 
    FEdit:TEdit; 
    OKButton,CancelButton:TButton; 
    filename:string; 
    DS:formatT; 
Begin 
 FormatBoxForm:=TForm.create(form2); 
 with formatBoxForm do begin 
   Width := 300; 
   Height:= 100; 
   Left  :=Trunc((Screen.Width-Width)/2); 
   Top   :=Trunc((Screen.Height-Height)/2); 
   Caption := 'Format hinzufügen'; 
   BorderStyle := bsSingle; 
 end;


bei diesem Fenster - sagen wie ich will wenn man auf den Ok Button klickt das in dem FEdit feld jetzt eine berechnung angezeigt wird. Dazu brauche ich die OnClick Procedure beim OKButton. So aber wenn ich da jetzt auf eine procedure Berechnen verweise die dann auf das Edit zugreift dann muß das Editfeld global deklariert werden und ich möchte es jedoch nur lokal deklarieren wie in dieser procedur.

Moderiert von user profile iconPeter Lustig: Code- durch Delphi-Tags ersetzt