Autor Beitrag
Niko S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 566
Erhaltene Danke: 10

Win 7, Ubuntu
Lazarus, Turbo Delphi, Delphu 7 PE
BeitragVerfasst: Mo 19.01.09 18:26 
Also ich möchte bei einer MDI anwendung meine Forms nicht sofort angezeigt bekommen und wenns nötig ist auch wieder zerstören. Nur wie Prüfe ich ob die Form bzw diese Variable schon gesetzt/vorhanden ist ?

Bevor ich
ausblenden Delphi-Quelltext
1:
Application.CreateForm(TForm2, Form2);					

mache ist die Variable oder Class nicht gesetzt...

Ich kann ja durch den befehl beliebig viele Fenster erschaffen die wie Form2 sind aber ich möchte dass es nur 1 mal ist und nicht beliebig viele, da ich nicht alle ansteuern kann wen nich die zur laufzeit erschaffe.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mo 19.01.09 18:46 
Hierzu empfiehlt sich, die Variable (die Delphi-Intern ja ein Pointer ist!) auf nil zu prüfen, oder (sauberer&lesbarer):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
   if Assigned (aFormVariable) then
     //Form schon erstellt
   else
     //erstmal erstellen

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 20.01.09 08:50 
Dann muss man beim Zerstören der Form aber sicherstellen, dass die Variable auch wieder nil gesetzt wird. Sonst passiert beim zweiten Versuch die Form zu erzeugen nichts.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 20.01.09 08:54 
...was sich ja einfach machen lässt, wenn man nicht MyForm.Free sondern FreeAndNil(MyForm) benutzt. :D

_________________
We are, we were and will not be.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 20.01.09 08:58 
Nun verrate doch nicht gleich alles. :P