Tengo una aplicación MDI, en la cual voy creando las MDIChild a medida que las necesito y las destruyo al cerrar las mimas, esto sin problemas.
Pero quiciera hacer que solo me permita una forma MDIChild a la vez, es decir, si creo una forma, y luego intento crear otra, primero, verificar si alguna forma esta creada y luego cerrarla y destruirla, recien ahi crear la nueva forma.
Como puedo hacer esto?
Yo las creo asi
Código Delphi
[-]
MDIChild1:=TMDIChild1.Create(self);
y la destruyo en OnClose, asi:
Código Delphi
[-]
MDIChild1 := nil;
action := cafree;
Intente hacer lo siguiente, para determinar si hay otra forma creada, asi
Código Delphi
[-]
procedure cerrameformas;
begin
if assigned(MDIChild1) then MDIChild1 Close;
if assigned(MDIChild2) then MDIChild2 Close;
if assigned(MDIChild3) then MDIChild3 Close;
end;
begin
cerrameformas;
MDIChild1:=TMDIChild1.Create(self);
end;
Funcioar, me funciona, pero... si lo ejecuto un par de veces seguidas, me tira error. Como tendria que hacer??
Saludos y gracias