Aplicação MDI, como verifico se um form já foi criado?
Como eu consigo verificar se um form já foi criando em uma aplicação MDI?
Desde já agradeço!!
Fabíola
Desde já agradeço!!
Fabíola
Fea
Curtidas 0
Respostas
Biscalquini
22/09/2003
insira a seguinte função no seu Formulário Principal
function TFmPrincipal.Existe(Formulario: TForm) : boolean;
var
I: integer;
begin
Result:=false;
for I:=0 to ComponentCount-1 do
if (Components[I] is TForm) then
if (TForm(Components[I])=Formulario) then
Result:=True;
end;
Como usar:
if Existe(FmCadastro)=False then
FmCadastro:=TFmCadastro.Create(Self);
FmCadastro.BringToFront;
Pronto!!!
function TFmPrincipal.Existe(Formulario: TForm) : boolean;
var
I: integer;
begin
Result:=false;
for I:=0 to ComponentCount-1 do
if (Components[I] is TForm) then
if (TForm(Components[I])=Formulario) then
Result:=True;
end;
Como usar:
if Existe(FmCadastro)=False then
FmCadastro:=TFmCadastro.Create(Self);
FmCadastro.BringToFront;
Pronto!!!
GOSTEI 0
E_gama
22/09/2003
Uma boa prática é:
- No Form MDIChild, escreva o evento ´OnClose´:
- No Form MDI, ao chamar um Child:
Exemplo: Form1 = MDI e Form2 = MDIChild:
Form1:
Form2: (evento OnClose)
- No Form MDIChild, escreva o evento ´OnClose´:
Action := caFree; <NomeFormChild> := nil; //
- No Form MDI, ao chamar um Child:
if <NomeFormChild> = nil then // procecedimentos para criar o form child; <NomeFormChild>.WindowState := wsNormal;
Exemplo: Form1 = MDI e Form2 = MDIChild:
Form1:
if Form2 = nil then Application.CreateForm(TForm2, Form2); Form2.WindowState := wsNormal;
Form2: (evento OnClose)
Action := caFree; Form2 := nil;
GOSTEI 0