Show forms with animation  

Send By: casimaxi
Web : N.A.
Email: N.A.
Date: 07/06/20

Tip accessed 709 times

 


Instead of showing a FormX by means of:

 FormX.Show;


we can use the Windows API function: AnimateWindow

In order to prove this, put a TButton (Button1) in your form, and in its OnClick event place this code:

 procedure TForm1.Button1Click(Sender: TObject);

   procedure ShowFormAnimated(TheForm:TForm);
   begin
     TheForm.BringToFront;
     AnimateWindow(TheForm.Handle,2000,AW_CENTER);
     TheForm.Show;
   end;

 begin
   //Ocultamos Form1
   Form1.Hide;

   //La mostramos con animacion
   ShowFormAnimated(Form1);
 end;



The function admits several forms of animation, are the following ones:

 AW_HOR_NEGATIVE
 AW_VER_POSITIVE
 AW_VER_NEGATIVE
 AW_BLEND  //solo en Windows 2000
 AW_CENTER
 AW_HOR_POSITIVE



it even admits combinations of several of them, for example, to obtain an animation in diagonal:

 AnimateWindow(TheForm.Handle,2000,AW_HOR_POSITIVE+AW_VER_POSITIVE);