Fórum Como Criar um Form assim ? #292513
21/08/2005
0
function ExisteForm(pForm: Tform): Boolean;
var i : integer;
begin
ExisteForm := False;
for i := 0 to Screen.FormCount - 1 do
if Screen.Forms[i] = pForm then
begin
ExisteForm := True;
Break;
end;
end;
[b:1de41140ca]que a uso assim :[/b:1de41140ca]
if ExisteForm([b:1de41140ca]form2[/b:1de41140ca]) = false then begin
[b:1de41140ca]form2 [/b:1de41140ca]:= T[b:1de41140ca]Form2[/b:1de41140ca].Create(self);
[b:1de41140ca]Form2[/b:1de41140ca].Show;
end;
Gostaria de criar mais uma variável na minha função onde iria receber o nome do Form à ser aberto, e colocar o [b:1de41140ca]if acima [/b:1de41140ca]na função para facilitar o uso da mesma.
[b:1de41140ca]Como ficaria a minha funcão entao ??????[/b:1de41140ca]
Fabiano Góes
Curtir tópico
+ 0Posts
21/08/2005
Rjun
if form2 = nil then begin form2 := TForm2.Create(nil); form2.Show; end;
Gostei + 0
21/08/2005
Fabiano Góes
if form2 = nil then
begin
form2 := TForm2.Create(nil);
form2.Show;
end;
[b:49ba03bfb3]Tipo[/b:49ba03bfb3]:
procedure AbreForm([b:49ba03bfb3]variavel [/b:49ba03bfb3]?);
begin
if [b:49ba03bfb3]Variavel [/b:49ba03bfb3]= nil then
begin
[b:49ba03bfb3]Variavel [/b:49ba03bfb3]:= T[b:49ba03bfb3]Variavel[/b:49ba03bfb3].Create(nil);
[b:49ba03bfb3]Variavel[/b:49ba03bfb3].Show;
end;
end;
o meu problema esté em como criar essa variavel, e criar o form com o nome da variavel:
variavel.Create(nil)
Gostei + 0
22/08/2005
Paullsoftware
[color=green:f5d8354fc7][i:f5d8354fc7]// Verifica se o form a ser criado já esta carregado[/i:f5d8354fc7][/color:f5d8354fc7]
[b:f5d8354fc7]function FormExiste(aberto: Tform): Boolean;
var
I:Integer;
begin
FormExiste := false;
for I := 0 to Screen.FormCount -1 do
if Screen.Forms[i] = aberto then
begin
FormExiste := true;
Break;
end
end;[/b:f5d8354fc7]
[b:f5d8354fc7]daí é só usar a função pra testar:[/b:f5d8354fc7]
if FormExiste(FormRetorno) then begin FormRetorno.BringToFront; FormRetorno.Focused; end else begin FormRetorno:=TFormRetorno.Create(Self); FormRetorno.BringToFront; FormRetorno.Focused; end;
espero ter ajudado... :wink:
Gostei + 0
22/08/2005
Fabiano Góes
var
FormRetorno : TForm;
begin
FormRetorno:= Form2;
Quando Chega na linha :
[b:f053543653]FormRetorno := TFormRetorno.Create(Self);[/b:f053543653]
ai acontece o erro(o meu problema)
Undeclared identifier: ´TFormRetorno´
não sei se deu pra entender, mais te agradeço a atenção mesmo assim.
Gostei + 0
22/08/2005
Massuda
Gostei + 0
22/08/2005
Fabiano Góes
Achei a solução que inclusive foi vc mesmo que respondeu,
a soluição foi assim:
procedure CriaForm(ClasseDoForm: TFormClass);
var
Form: TForm;
begin
Form := ClasseDoForm.Create(Application.MainForm);
Form.ShowModal;
Form.Free;
end;
// exemplo de uso
// CriarForm(TFrmCadastro);
Valeu Massuda !!!!!!!!!!!!!! :lol:
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)