Fórum Aplicação MDI, como verifico se um form já foi criado? #183594
22/09/2003
0
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
Curtir tópico
+ 0
Responder
Posts
23/09/2003
Biscalquini
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!!!
Responder
Gostei + 0
23/09/2003
E_gama
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;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)