Autor Beitrag
Karstadt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Do 01.12.05 10:39 
Hallo. Ich habe einen MDI Anwendung.

Mit TForm2.Create(self) mache ich ein Formular auf. Nun möchte ich mit einen Knopf diesen Formular von fsMDIForm schließen. Wie geht das?
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: Do 01.12.05 11:24 
So schließe ich bei mir alle MDIChilds:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  // Solange es Childs gibt:
  while MDIChildCount > 0 do
  begin
    // Ist es ein Kind der aktuellen Form?
    if TForm(MDIChildren[MDIChildCount - 1]).Owner = self then
    begin
      // Falls ja, dann machs dicht
      TForm(MDIChildren[MDIChildCount - 1]).Close;
    end;
    // Ein bisschen Systemzeit ....
    Application.ProcessMessages;
  end;

Du kannst noch weitere Prüfungen einbauen, um genau das eine Fenster zu erwischen.


Zuletzt bearbeitet von jasocul am Do 01.12.05 13:55, insgesamt 1-mal bearbeitet
Karstadt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Do 01.12.05 13:17 
Hallo das ist super!

Ich weis zwar nicht was du mit diese Prozedur genau machst. Schließst du etwa alle "TFORM" ?

TForm2(MDIChildren[MDIChildCount - 1]).Close;

Ich habe es damit probiert, funktioniert! Supereinfach. Nächste Frage ist wie spreche ich diese Funktion mit FindComponent an?

TForm(FindComponent('TForm2')).MDIChildren[MDIChildCount - 1].Close;

Dass funktioniert leider net :(
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: Do 01.12.05 14:00 
Habe ein paar Kommentare in den Source geschrieben.

Mit deiner Art FindComponent zu benutzen, wirst du nicht weiter kommen. Du suchst nach dem Klassenbezeichner (TForm2), musst aber nach dem Namen suchen (vrmtl. Form2). Ich habe das aber mit MDIChilds noch nie ausprobiert.
Karstadt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Do 01.12.05 15:49 
Danke für deine Hilfe mit MDIChildren das funktioniert sehr einfach!
Karstadt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Fr 02.12.05 08:23 
Hallo. Kannst du mir bitte in folgende Sitation helfen.

In einer fsMDIChild will ich eine ander fsMDIChild Form aufrufen. Diese Form (fsMDIChild) soll aber natürlich fsMDIForm erscheinen.

Sollte eingentlich so funktionieren: Tf_bauarbeiteransicht.Create(f_hauptform)

leider kann ich die hauptform in der Tochterform nicht ansprechen
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: Fr 02.12.05 09:04 
Benutze mal TForm(Owner) statt f_hauptform.
Ansonsten musst du die Hauptform im Uses mit aufnehmen.

P.S.: Und denke nächstes mal daran: Neue Frage, neues Topic.
Karstadt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 174

Windows 2000 / XP
Delphi 7 Pro
BeitragVerfasst: Fr 02.12.05 10:26 
Alle klar!