form2.showmodal;
接著新增一個新的視窗為form2,並加入一個timer,其enabled=true 及 interval=100,並記得加入事件喔。最後新增一'離開的'按鈕,然後編輯程式碼如下:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Timer1Timer(Sender: TObject);
var
i,j:integer;
begin
timer1.Enabled:=false;
i:=0;
j:=3;
while(i<255) do
begin
i:=i+j;
form2.AlphaBlendValue:=i;
end;
form2.AlphaBlendValue:=255;
end;
procedure TForm2.FormShow(Sender: TObject);
begin
form2.AlphaBlend:=true;
form2.AlphaBlendValue:=0;
timer1.Enabled:=true;
end;
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
var
i,j:integer;
begin
i:=255;
j:=3;
while(i>0) do
begin
i:=i-j;
form2.AlphaBlendValue:=i;
end;
form2.AlphaBlendValue:=0;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
close;
end;
end.
沒有留言:
張貼留言