How to fade forms in and out #179

This is more an aesthetical feature but you can easily add fading in / out to your project with this simple snippet.

To fade in:

var
  j : Integer;
begin
  j := 0;
  while j < 255 do 
   j := j + 1;
   Form1.AlphaBlendValue := j;
end;

To fade out

var
  j : Integer;
begin
  j := 255;
  while j > 0 do 
    j := j - 1;
    Form1.AlphaBlendValue := j;
  end;
end;

You could refactor this code to work with a timer rather than using a loop.

Code slightly modified and corrected by Peter Johnson.

Author: K Smith
Contributor: K Smith
Added: 2011/01/15
Last updated: 2011/01/15