![]() |
MDICild nicht 2 mal öffnen
Hallo zusammen,
ich stehe im Moment total im Wald. Ich öffne ein MDICHILD über ein MainMenu wie folgt.
Delphi-Quellcode:
Ok das klappt auch, nun wie kann ich es verhindern das die Form ein zweitesmal aufgerufen wird??
TForm2.Create(self).
Danke Bodo :wall: |
Re: MDICild nicht 2 mal öffnen
Hi,
da gibt es verschiedene Ansätze. Du könntes über Screen.Forms iterieren und prüfen, ob es ein Formular dieser Klasse oder mit dem Namen gibt. Dann kannst du mit der Formularvariablen arbeiten. Dazu musst du aber mit
Delphi-Quellcode:
das Formular öffnen und organisieren, dass beim Schliessen vom Form die Variable wieder auf nil gesetzt wird.
if not Assigned(Form2) then
Form2 := TForm2.Create(self); Cu, Frank |
Re: MDICild nicht 2 mal öffnen
Hallo dataspider,
danke für deine schnelle Antwort. Hab es hinbekommen. Danke Bodo |
Re: MDICild nicht 2 mal öffnen
Zitat:
ich habe das mal etwas komplizierter gelöst. Ich rufe alle Forms mit einer Aufrufroutine auf und lege beim Aufruf fest, in welcher Art das Fenstergeöffnet werden soll.
Delphi-Quellcode:
fmMulti - Beliebig oft als MDI öffnen
Function ShowForm(aOwner : TComponent;
Form : TFormClass; Modus : TFormmodus; TagId : Integer) : TForm; Function GetMDIChild : TForm; var i : Integer; Begin result:=nil; if (Application.MainForm = nil) or (Application.MainForm.MDIchildcount = 0) then Exit; for i:=0 to Application.MainForm.MDIchildcount-1 do if Application.MainForm.MDIChildren[i].ClassName = Form.ClassName then Begin result:= Application.MainForm.MDIChildren[i]; if result.WindowState = wsMinimized then result.Windowstate := wsnormal; Exit; end; end; Function FindMDIChild : TForm; var i : Integer; Begin result:=nil; if (Application.MainForm = nil) or (Application.MainForm.MDIchildcount = 0) then Exit; for i:=0 to Application.MainForm.MDIchildcount-1 do if (Application.MainForm.MDIChildren[i].ClassName = Form.ClassName) and (TagId = Application.MainForm.MDIChildren[i].Tag) then Begin result:= Application.MainForm.MDIChildren[i]; if result.WindowState = wsMinimized then result.Windowstate := wsnormal; Exit; end; end; Begin result:=nil; Case Modus of fmMulti : Begin result:= Form.Create(AOwner); if result.Formstyle <> fsMDIChild then result.Formstyle:=fsMDIChild; end; fmsingle : Begin result:=GetMDIChild; if result=nil then result:= Form.Create(AOwner); if result.Formstyle <> fsMDIChild then result.Formstyle:=fsMDIChild; end; fmsingleTag: Begin result := FindMDIChild; FormExists := result <> nil; if (result = nil) then Begin result := Form.Create(AOwner); result.Tag := TagID; end; if result.Formstyle <> fsMDIChild then result.Formstyle:=fsMDIChild; end; fmmodal : begin result:= Form.Create(AOwner); result.visible:=false; result.FormStyle:=fsnormal; if result.Width > TForm(aOwner).ClientWidth-4 then result.left:=2 else result.Left:=(TForm(aOwner).ClientWidth-result.Width) shr 1; if result.Height < TForm(aOwner).ClientHeight-4 then result.Top:= (TForm(aOwner).ClientHeight - result.Height) shr 1 else result.Top:=2; result.ShowModal; result.Free; Result:=nil; Exit; end; fmnormal : begin result:= Form.Create(AOwner); result.visible:=false; result.FormStyle:=fsnormal; if result.Width > TForm(aOwner).ClientWidth-4 then result.left:=2 else result.Left:=(TForm(aOwner).ClientWidth-result.Width) shr 1; if result.Height < TForm(aOwner).ClientHeight-4 then result.Top:= (TForm(aOwner).ClientHeight - result.Height) shr 1 else result.Top:=2; Application.Processmessages; Exit; end; fmTop : begin result:= Form.Create(AOwner); result.visible:=false; result.FormStyle:=fsStayOnTop; if result.Width > TForm(aOwner).ClientWidth-4 then result.left:=2 else result.Left:=(TForm(aOwner).ClientWidth-result.Width) shr 1; if result.Height < TForm(aOwner).ClientHeight-4 then result.Top:= (TForm(aOwner).ClientHeight - result.Height) shr 1 else result.Top:=2; Application.Processmessages; end; end; if result <> nil then Begin Application.Processmessages; result.Show; end; end; fmsingle - Nur einmal als MDI öffnen, bei erneuten aufruf Focus auf vorhandenes Fenster fmsingleTag - Nur einmal pro Vorgang öffnen. z.B. jeweils für neue Kundenbearbeitung bei öffnen für bereits geöffneten Kunden nur Focus setzen fmmodal - Öffnen als modales Fenster fmnormal - Normal öffnen mit .Show. fmTop - stay on Top Gruß Peter |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz