Fórum Como posso Impedir diversas aberturas de um mesmo form MDI #324944

07/07/2006

0

Estou com um probleminha, como posso impedir diversas aberturas de um mesmo form MDIChield. tentei o FindWindow, mas ñ obtive exito.
Desde já obrigado galera.


Cabal

Cabal

Responder

Posts

07/07/2006

Paullsoftware

cria essa função:
// Verifica se o form a ser criado já esta carregado
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;
e para usar faz assim:
if not FormExiste(FrmCadClientes) then
   begin
     FrmCadClientes := TFrmCadClientes.Create(nil);
     FrmCadClientes.BringToFront;
     FrmCadClientes.Focused;
   end
  else
   begin
     FrmCadClientes.BringToFront;
     FrmCadClientes.Focused;
   end;
espero ter ajudado :wink:


Responder

Gostei + 0

07/07/2006

Aasn

Caro Cabal,

é bem simples:

procedure TForm1.Button1Click(Sender: TObject);
var i : integer;
begin
{ verifica se ja existe o form aberto }
for i := 0 to MDIChildCount -1 do
    if MDIChildren[i].ClassType = TForm2 then
       Abort;
{ caso nao exista cria e abre }
Application.CreateForm(TForm2, Form2);
Form2.Show;
end;


[]´s
AASN


Responder

Gostei + 0

07/07/2006

Imoreira

if not assigned(SeuForm) then begin
application.createform(TSeuForm,SeuForm);
SeuForm.show;
end else begin
SeuForm.WindowState:=wsNormal;
SeuForm.BringToFront;
end;

No onClose do SeuForm faça:

SeuForm:=nil;


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar