Buscar

Animar form sem componente

Código

Você pode animar seu form de uma forma divertida e sem componentes, apenas uma procedure.

/////PROCEDURE PARA EXECUTAR TAREFA

procedure TForm1.Animar_Form(Qtd_quadros,V_sleep,V_width,V_height: integer;status_fechar:Boolean);
var V_sub_width, V_sub_heigth, pt_medio : integer;
begin

with Form1 do begin

  if status_fechar then begin  ////////////FECHANDO O FORM


    V_sub_width := (V_Width div qtd_quadros);
    V_sub_heigth := (V_Height div qtd_quadros);
    pt_medio := 1;

    while pt_medio <= (qtd_quadros div 2) do begin
          pt_medio := pt_medio + 1;
          Top := Top + V_sub_heigth;
          Left := Left + V_sub_width;
          Width := Width - (V_sub_width+10);
          Height := Height - (V_sub_heigth+10);
          Application.ProcessMessages;
          sleep(V_sleep);
    end;

  end else begin  /////////////ABRINDO O FORM NOVAMENTE

    V_sub_width := (V_Width div qtd_quadros);
    V_sub_heigth := (V_Height div qtd_quadros);
    pt_medio := 1;

    while pt_medio <= (qtd_quadros div 2) do begin
          pt_medio := pt_medio + 1;
          Top := Top - V_sub_heigth;
          Left := Left - V_sub_width;
          Width := Width + (V_sub_width + 10);
          Height := Height + (V_sub_heigth + 10);
          Application.ProcessMessages;
          sleep(V_sleep);
    end;

  end;

end;
end;

///////CHAMANDO A PROCEDURE
//////PARA FECHAR O FORM
  Animar_Form(30,10,Form1.Width,Form1.Height, true);

/////PARA ABRIR O FORM
  Animar_Form(30,10,500,200, false);
 
O 30 -> Quatidade de quadros, eu uso em média 30 quadros
O 10 -> Sleep do projeto ou seja o tempo necessário de intervalo de quadros
O 500 -> Tamanho do form em width
O 200 -> Tamanho do form em Height


Boa Sorte

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Forms
Adicionada dia: 01/07/08
Por: Roberto Junior
Visualizada: 5005 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009