Autor Beitrag
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 10:26 
Hi,
Ich erstelle meine MDIChilds mit dieser funktion:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TEditorForm.CreateViewPort(const Name: string);
var
  ViewPort: TEditorViewPortForm;
begin
  { create a new MDI child window }
  ViewPort := TEditorViewPortForm.Create(EditorForm);
  ViewPort.Caption := Name;
end;


Nun möchte ich aber die Funktion im Form.Create aufrufen, da direkt bei programmstart 4 MDIChilds erstellt werden sollen, nur dann bekomme ich den fehler: Cannot create form. No MDI forms are currently active.
Meine Frage: Kann man das umgehen? ist es überhaupt möglich childs im oncreate zu erstelen?

//Edit:Der selbe Fehler kommt auch wenn ich die Childs im OnShow oder im OnActivate erzeuge

mfg matze

_________________
si tacuisses, philosophus mansisses.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 07.01.05 12:35 
Bist du sicher, dass EditorForm.FormStyle auf fsMDIForm steht? Das muss nämlich sein. Wodrin sollten die Childs denn sonst erzeugt werden und die Fehlermeldung lautet, dass keine solche MDIForm da ist.
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 12:41 
jap die Form steht auf MDIForm und wenn ich die Childs mit einem button erzeuge klappt es ja aber ich muss wenn man in das programm reingeht 4 childs haben und die wollte ich im oncreate erstellen.

mfg matze

_________________
si tacuisses, philosophus mansisses.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Fr 07.01.05 12:44 
Versuch mal nicht die Variable ViewPort zu belegen, sondern nur TEditorViewPortForm.Create(EditorForm); 4x aufzurufen
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 12:53 
bei TEditorViewPortForm.Create(EditorForm); kommt genau der selbe fehler :/

mfg matze

_________________
si tacuisses, philosophus mansisses.
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 07.01.05 12:58 
Probier mal:
ausblenden Delphi-Quelltext
1:
  ViewPort := TEditorViewPortForm.Create(Self);					

Falls es das nicht war, prüfe doch mal, ob es funktioniert, wenn du die MDIChilds nicht erst zur Laufzeit generierst. Also in den Projekt-Optionen bei den automatisch erstellten stehen lässt.
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 13:01 
mit 'self' geht das auch nicht, selber fehler. die form 'EditorViewPortForm' steht nicht im autocreate.

mfg matze

_________________
si tacuisses, philosophus mansisses.
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 13:03 
während der laufzeit erstellen funktioniert ja aber wie mache ich das dann, dass er wenn das programm gestartet ist 4 stück erstellt?

mfg matze

_________________
si tacuisses, philosophus mansisses.
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 07.01.05 13:15 
Nach einigem überlegen fiel mir ein, dass ich mal ein ähnliches Problem hatte.
Das ganze funktioniert erst, wenn die MDIForm aktiv ist. Deswegen geht das in den von dir genannten Ereignissen nicht.
Ich habe das gelöst, indem ich die Procedure UpdateActions (unter protected und da mit override) eingebunden habe.
Da diese Procedure ähnlich wie Idle arbeitet, musst du noch einiges bedenken. Da sie bei Inaktivität der Form immer wieder durchlaufen wird, musst du sicherstellen, dass das Erzeugen deiner 4 Childs nur einmal aufgerufen wird. Dies habe ich gelöst, indem ich eine Boolesche Variable im OnCreate auf True gesetzt habe, diese dann in UpdateActions prüfe und nach dem Erstellen der Childs auf False gesetzt habe.
Wenn das jetzt zu kompliziert war, dann sag bescheid. Ich suche dann die Sourcen mal raus.
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 13:32 
Wäre es nicht einfacher, die Erzeugung der 4 Kinder im OnCreate eines anderen Forms zu machen? Notfalls einfach ein zusätzliches (Dummy-)Form einbinden und gut. Die Forms werden nacheinander created, und wenn Dummy dran ist, existiert das Hauptform schon längst und die Kinderchen können gezeugt werden. :mrgreen:
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 13:45 
kann man die nicht selber vorher aktivieren?

mfg matze

_________________
si tacuisses, philosophus mansisses.
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 07.01.05 13:45 
Ich mag Dummies nicht.
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 13:51 
matze.de hat folgendes geschrieben:
kann man die nicht selber vorher aktivieren?

mfg matze


Was meinst du damit?
matze.de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Fr 07.01.05 13:51 
habs nun in einer anderen form gemacht die sowieso unabdingbar ist :)

danke an euch alle

mfg matze

_________________
si tacuisses, philosophus mansisses.
IngoD7
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 629


D7
BeitragVerfasst: Fr 07.01.05 14:08 
matze.de hat folgendes geschrieben:
habs nun in einer anderen form gemacht die sowieso unabdingbar ist :)


Ich kann helfen ... :lol:

Und wenn du es noch früher brauchst, dann kannst du eine Procedure "KinderErzeugen" in dein Hauptform einbauen und in der Projektdatei sowas hier machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Form1.KinderErzeugen;
  Application.CreateForm(TForm2, Form2);
  ...
  Application.Run;
end.