因需要根据不同星期自动调用不同屏保图片,自己动手做了一个
代码如下:
//主工程文件
program scrsave;usesForms,Unit1 in 'Unit1.pas' {Form1};{$R *.res}beginApplication.Initialize;Application.Title := '横店屏保一';Application.CreateForm(TForm1, Form1);Application.Run;
end.//单元文件
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, ExtCtrls, StdCtrls, JPEG;typeTForm1 = class(TForm)Timer1: TTimer;procedure FormDestroy(Sender: TObject);procedure FormCreate(Sender: TObject);procedure FormShow(Sender: TObject);procedure Timer1Timer(Sender: TObject);procedure LoadImage(img: TBitmap; cFile: String);procedure FormMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);procedure FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);privateprocedure FindFiles(sPath: string);procedure Detect(var Msg: TMsg; var Handled: Boolean);procedure BackClear;//清屏procedure HundredLeaf(cFile: string); //百叶窗procedure PushDrag(cFile: string);//推拉procedure HorizonCross(cFile: string);//水平交错procedure VericalCross(cFile: string);//垂直交错procedure PutStick(cFile: string); //积木procedure CenToAll(cFile: string);//中间到四周procedure AllToCen(cFile: string);procedure LUpToRDown(cFile: string);//左上到右下procedure RDownToLUp(cFile: string);//右下到左上procedure LDownToRUp(cFile: string);//左下到右上procedure RUpToLDown(cFile: string);//右上到左下procedure MidToBoth(cFile: string);//中间到两边procedure BothToMid(cFile: string);//两边到中间procedure FlowSand(cFile: string);//流沙{ Private declarations }public{ Public declarations }end;varForm1: TForm1;FilesList: TStringList;sFilePath: string;Stop: boolean;implementation
//{$D ScreenSave 我的屏幕保护}{$R *.dfm}procedure TForm1.FormDestroy(Sender: TObject);
beginFilesList.Free;
end;procedure TForm1.FormCreate(Sender: TObject);
varweek: Integer;
beginself.Color := clBlack;Stop := False;//按星期选择相应的文件夹week := DayOfWeek(Date());case week of1,2: sFilePath := ExtractFilePath(Application.ExeName)+'Hdds\monday';3: sFilePath := ExtractFilePath(Application.ExeName)+'Hdds\tuesday';4: sFilePath := ExtractFilePath(Application.ExeName)+'Hdds\wendsday';5: sFilePath := ExtractFilePath(Application.ExeName)+'Hdds\thursday';6,7: sFilePath := ExtractFilePath(Application.ExeName)+'Hdds\friday';end;FindFiles(sFilePath);//Self.FormStyle := fsStayOnTop;
end;procedure Tform1.FindFiles(sPath: string);
function FType(cFile: String): boolean;
vark :integer;ext: string;
beginresult := false;if Length(cFile) > 2 thenbegink := pos('.',cFile);ext := UpperCase(copy(cFile,k,length(cFile)-k+1));if (ext= '.JPEG') or (ext= '.JPG') or (ext= '.BMP') thenresult := true;end;
end;
varSearchRec: TSearchRec;
beginif not Assigned(FilesList) then FilesList:= TStringList.Create;FilesList.Clear;if FindFirst(sPath+'\*.*', 0, SearchRec)=0 thenbegintryrepeatif FType(SearchRec.Name) thenbeginFilesList.Add(sPath+'\'+SearchRec.Name);end;until FindNext(SearchRec)<>0;exceptFindClose(SearchRec);raise;end;FindClose(SearchRec);end;
end;procedure TForm1.Detect(var Msg: TMsg; var Handled: Boolean);
beginif (Msg.message = wm_keydown) or (Msg.message = wm_lbuttondown) or(Msg.message = wm_rbuttondown)thenbeginstop := true;Timer1.Enabled := True;close;end;
end;procedure TForm1.FormShow(Sender: TObject);
beginWindowState := wsMaximized;Self.BringToFront;ShowCursor(False);Application.OnMessage := Detect;
end;//百叶窗效果
procedure TForm1.HundredLeaf(cFile: string);
varBitTemp1,BitTemp2,Bitmap:TBitmap;i,j,bmpheight,bmpwidth:integer;xgroup,xcount:integer;
beginBitTemp1:= TBitmap.Create;//过渡位图BitTemp2:= TBitmap.Create;Bitmap := TBitmap.Create;BackClear;tryLoadImage(BitTemp1, cFile);BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(ClientRect, BitTemp1);Bitmap.Width := self.Width;Bitmap.Height := self.Height;bmpheight:=Height;bmpwidth:=Width;xgroup:=10;xcount:=bmpheight div xgroup;for i:=0 to xcount dofor j:=0 to xgroup dobeginsleep(10);Bitmap.Canvas.CopyRect(Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i),BitTemp2.Canvas,Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i)); self.Canvas.Draw(0,0,Bitmap);Application.ProcessMessages;if Stop then Exit;end;finallyBitmap.Free;BitTemp1.Free;BitTemp2.Free;end;
end;//=========================================================
//推拉效果
//==========================================================
procedure TForm1.PushDrag(cFile: string);
varBitTemp1,BitTemp2:TBitmap;//Bitmap:TBitmap;i,bmpheight,bmpwidth:integer;
beginBackClear; //清屏BitTemp1:= TBitmap.Create;//过渡位图BitTemp2:= TBitmap.Create;//Bitmap := TBitmap.Create;tryLoadImage(BitTemp1, cFile);BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(ClientRect, BitTemp1);//Bitmap.Width := self.Width;// Bitmap.Height := self.Height;bmpheight:=Height;bmpwidth:=Width;for i:=0 to bmpheight dobegin{Bitmap.Canvas.CopyRect(Rect(0,bmpheight-i,bmpwidth,bmpheight),BitTemp2.Canvas,Rect(0,0,bmpwidth,i));self.Canvas.Draw(0,0,Bitmap,); }BitBlt(Self.Canvas.Handle,0,bmpheight-i,bmpwidth,bmpheight,BitTemp2.Canvas.Handle,0,0,srcCopy);Application.ProcessMessages;if Stop then Exit;end;finally// Bitmap.Free;BitTemp1.Free;BitTemp2.Free;end;
end;//==============================================================
//水平交错
//==============================================================
procedure TForm1.HorizonCross(cFile: string);
varBitTemp1,BitTemp2,Bitmap:TBitmap;i,j,bmpheight,bmpwidth:integer;
begin//BackClear(cFile); //清屏BitTemp1:= TBitmap.Create;//过渡位图BitTemp2:= TBitmap.Create;Bitmap := TBitmap.Create;tryLoadImage(BitTemp1, cFile);BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(ClientRect, BitTemp1);Bitmap.Width := self.Width;Bitmap.Height := self.Height;bmpheight:=Height;bmpwidth:=Width;i:=0;while i<=bmpwidth dobeginj:=i;while j >0 dobeginBitmap.Canvas.CopyRect(Rect(j-1,0,j,bmpheight),BitTemp2.Canvas,Rect(bmpwidth-i+j-1,0,bmpwidth-i+j,bmpheight));Bitmap.Canvas.CopyRect(Rect(bmpwidth-j-1,0,bmpwidth-j,bmpheight),BitTemp2.Canvas,Rect(i-j,0,i-j+1,bmpheight));j:=j-3;Application.ProcessMessages;if Stop then Exit;end;Application.ProcessMessages;if Stop then Exit;self.Canvas.Draw(0,0,Bitmap);inc(i,3);end;Bitmap.Canvas.CopyRect(rect(0,0,Width,Height),BitTemp2.Canvas,rect(0,0,Width,Height));self.Canvas.Draw(0,0,Bitmap);sleep(500);finallyBitmap.Free;BitTemp1.Free;BitTemp2.Free;end;
end;//=======================================================================
//垂直交错
//========================================================================
procedure TForm1.VericalCross(cFile: string);
varBitTemp1,BitTemp2,Bitmap:TBitmap;i,j,bmpheight,bmpwidth:integer;
beginBackClear; //清屏BitTemp1:= TBitmap.Create;//过渡位图BitTemp2:= TBitmap.Create;Bitmap := TBitmap.Create;tryLoadImage(BitTemp1, cFile);BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(ClientRect, BitTemp1);Bitmap.Width := self.Width;Bitmap.Height := self.Height;bmpheight:=Height;bmpwidth:=Width;i:=0;while i<=bmpheight dobeginj:=i;while j >0 dobeginBitmap.Canvas.CopyRect(Rect(0,j-1,bmpwidth,j),BitTemp2.Canvas,Rect(0,bmpheight-i+j-1,bmpwidth,bmpheight-i+j));Bitmap.Canvas.CopyRect(Rect(0,bmpheight-j-1,bmpwidth,bmpheight-j),BitTemp2.Canvas,Rect(0,i-j,bmpwidth,i-j+1));j:=j-3;Application.ProcessMessages;if Stop then Exit;end;Application.ProcessMessages;if Stop then Exit;self.Canvas.Draw(0,0,Bitmap);i:=i+3;end;Bitmap.Canvas.CopyRect(rect(0,0,Width,Height),BitTemp2.Canvas,rect(0,0,Width,Height));self.Canvas.Draw(0,0,Bitmap);sleep(500);finallyBitmap.Free;BitTemp1.Free;BitTemp2.Free;end;
end;//===========================================================================
//积木效果
//===========================================================================
procedure TForm1.PutStick(cFile: string);
varBitTemp1,BitTemp2,Bitmap:TBitmap;i,j,x,y:integer;
beginBitTemp1:= TBitmap.Create;//过渡位图BitTemp2:= TBitmap.Create;Bitmap := TBitmap.Create;tryLoadImage(BitTemp1, cFile);BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(ClientRect, BitTemp1);Bitmap.Width := self.Width;Bitmap.Height := self.Height;self.Color := clBlack;i := 0;j := 0;for x:=0 to 20 dobeginfor y:=0 to 15 dobeginBitmap.Canvas.CopyRect(rect(i*50,j*50,(i+1)*50,(j+1)*50),BitTemp2.Canvas,rect(i*50,j*50,(i+1)*50,(j+1)*50));self.Canvas.Draw(0,0,Bitmap);i:=i+2;Application.ProcessMessages;if Stop then Exit;end;j:=j+2;i:=0;end;j:=1;i:=1;for x:=0 to 20 dobeginfor y:=0 to 15 dobeginBitmap.Canvas.CopyRect(rect(i*50,j*50,(i+1)*50,(j+1)*50),BitTemp2.Canvas,rect(i*50,j*50,(i+1)*50,(j+1)*50));self.Canvas.Draw(0,0,Bitmap);i:=i+2;Application.ProcessMessages;if Stop then Exit;end;j:=j+2;i:=1;end;i := 0;j := 0;for x:=0 to 20 dobeginfor y:=0 to 15 dobeginBitmap.Canvas.CopyRect(rect(i*50,(j+1)*50,(i+1)*50,(j+2)*50),BitTemp2.Canvas,rect(i*50,(j+1)*50,(i+1)*50,(j+2)*50));self.Canvas.Draw(0,0,Bitmap);i:=i+2;Application.ProcessMessages;if Stop then Exit;end;j:=j+2;i:=0;end;j:=1;i:=1;for x:=0 to 20 dobeginfor y:=0 to 15 dobeginBitmap.Canvas.CopyRect(rect(i*50,(j-1)*50,(i+1)*50,j*50),BitTemp2.Canvas,rect(i*50,(j-1)*50,(i+1)*50,j*50));self.Canvas.Draw(0,0,Bitmap);i:=i+2;Application.ProcessMessages;if Stop then Exit;end;j:=j+2;i:=1;end;finallyBitmap.Free;BitTemp1.Free;BitTemp2.Free;end;
end;procedure TForm1.Timer1Timer(Sender: TObject);
vari,j : Integer;
beginTimer1.Enabled := False;Randomize;i := 0;while not stop dobeginj := 1+Random(13);case j of1: HundredLeaf(FilesList.Strings[i]);2: PushDrag(FilesList.Strings[i]);//推拉3: HorizonCross(FilesList.Strings[i]);//水平交错4: VericalCross(FilesList.Strings[i]);//垂直交错5: PutStick(FilesList.Strings[i]); //积木6: CenToAll(FilesList.Strings[i]); //中心到四周7: AllToCen(FilesList.Strings[i]);8: LUpToRDown(FilesList.Strings[i]);//左上到右下9: RDownToLUp(FilesList.Strings[i]);//右下到左上10: LDownToRUp(FilesList.Strings[i]);//左下到右上11: RUpToLDown(FilesList.Strings[i]);//右上到左下12: MidToBoth(FilesList.Strings[i]);//中间到两边13: BothToMid(FilesList.Strings[i]);//两边到中间14: FlowSand(FilesList.Strings[i]);//流沙end;Sleep(2000);if stop thenbeginTimer1.Enabled := True;exit;end;inc(i);if i >= FilesList.Count then i := 0;end; //whileend;procedure TForm1.LoadImage(img: TBitmap; cFile: String);
varext: String;jpgimg: TJpegImage;beginext := ExtractFileExt(cFile);if (UpperCase(ext) = '.JPG') or (UpperCase(ext) = '.JPEG') thenbeginjpgimg := TJpegImage.Create;tryjpgimg.LoadFromFile(cFile);img.Assign(jpgimg);finallyjpgimg.Free;end;endelse img.LoadFromFile(cFile);
end;procedure TForm1.BackClear;//清黑屏
conststep = 100;
varBitTemp, Bitmap : TBitmap;i : integer;
begin
// self.color := clBlack;
// repaint;BitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;LoadImage(BitTemp, ExtractFilePath(Application.ExeName) + 'Hdds\Monday\Back.bmp');//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;//Bitmap.Canvas.Brush.Color := clBlack;Bitmap.Canvas.StretchDraw(ClientRect, BitTemp);for i := 1 to step doBitBlt(self.Canvas.Handle,0,step-i,Width,Height,Bitmap.Canvas.Handle,0,0,blackness);Bitmap.Free; //释放位图BitTemp.Free;
end;procedure TForm1.CenToAll(cFile: string);//中间到四周
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;X0,Y0:integer;i,MidX,MidY:integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);x0:=width div 2;y0:=height div 2;ratiox:=Bitmap.width/step; //step每加1,图片变化的宽度ratioy:=Bitmap.height/step;for i:=0 to step dobeginmidx:=round(ratiox*i*0.5);midy:=round(ratioy*i*0.5);bitblt(self.canvas.handle,x0-midx,y0-midy,round(ratiox*i),round(ratioy*i),bitmap.canvas.handle,x0-midx,y0-midy,srccopy);//循环拷贝一定区域的图象显示,区域不断变化实现特效显示Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.AllToCen(cFile: string);//四周到中间
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i :integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;ratioy:=height/step;for i:= 0 to step dobegin //由于bitblt每次只能拷贝一个矩形,故要实现//从四周到中间的渐变显示特效,需要每次拷贝周边的//四个矩形,组成一个矩形框,bitblt(self.canvas.handle,0,0,round(ratiox*i*0.5),height,bitmap.canvas.handle,0,0,srccopy);//拷贝左边的矩形bitblt(self.canvas.handle,0,0,width,round(ratioy*i*0.5),bitmap.canvas.handle,0,0,srccopy);//拷贝上方的矩形bitblt(self.canvas.handle,width-round(ratiox*i*0.5),0,width,height,bitmap.canvas.handle,width-round(ratiox*i*0.5),0,srccopy);//拷贝右边的矩形bitblt(self.canvas.handle,0,height-round(ratioy*i*0.5),width,height,bitmap.canvas.handle,0,height-round(ratioy*i*0.5),srccopy);//拷贝下面的矩形Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.LUpToRDown(cFile: string);//左上到右下
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;ratioy:=height/step;for i:= 0 to step dobeginbitblt(self.canvas.handle,0,0,round(ratiox*i),round(ratioy*i),bitmap.canvas.handle,0,0,srccopy);//拷贝左上角的一个矩形,要求右下角的坐标//按(round(ratiox*i),round(ratioy*i))变化,//注意,由于宽和高不等,所以它们的变化幅度//也应该有所不同。Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.RDownToLUp(cFile: string);//右下到左上
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;ratioy:=height/step;for i:= 0 to step dobeginbitblt(self.canvas.handle,width-round(ratiox*i),height-round(ratioy*i),width,height,bitmap.canvas.handle,width-round(ratiox*i),height-round(ratioy*i),srccopy);Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.LDownToRUp(cFile: string);//左下到右上
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;ratioy:=height/step;for i:= 0 to step dobeginbitblt(self.canvas.handle,0,height-round(ratioy*i),round(ratiox*i),height,bitmap.canvas.handle,0,height-round(ratioy*i),srccopy);Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.RUpToLDown(cFile: string);//右上到左下
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX,RatioY:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;ratioy:=height/step;for i:= 0 to step dobeginbitblt(self.canvas.handle,width-round(ratiox*i),0,width,round(ratioy*i),bitmap.canvas.handle,width-round(ratiox*i),0,srccopy);Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.MidToBoth(cFile: string);//中间到两边
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);RatioX:=width/step;for i:= 0 to step dobegin//注意此时左上角的x坐标朝左变化,而右下角的x坐标朝右变化bitblt(self.canvas.handle,round(width/2)-round(ratiox*i*0.5),0,round(ratiox*i),height,bitmap.canvas.handle,round(width/2)-round(ratiox*i*0.5),0,srccopy);Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.BothToMid(cFile: string);//两边到中间
constStep=1600; //循环的次数,用以调整图象变动的快慢
varBitmap, BitTemp:TBitmap;i:integer;RatioX:real;
beginBitTemp := TBitmap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp, cFile);//载入图片Bitmap.Width := self.Width;Bitmap.Height := self.Height;Bitmap.Canvas.StretchDraw(self.ClientRect, BitTemp);ratiox:=width/step;for i:= 0 to step dobegin//实际是从四周到中心变化的简化。bitblt(self.canvas.handle,0,0,round(ratiox*i*0.5),height,bitmap.canvas.handle,0,0,srccopy);bitblt(self.canvas.handle,width-round(ratiox*i*0.5),0,width,height,bitmap.canvas.handle,width-round(ratiox*i*0.5),0,srccopy);Application.ProcessMessages;if Stop then Exit;end;finallybitmap.free; //释放位图BitTemp.Free;end;
end;procedure TForm1.FlowSand(cFile: string);//流沙
varBitmap, BitTemp1, BitTemp2:TBitmap;i,j:integer;
beginBitTemp1 := TBitmap.Create;BitTemp2 := TBitMap.Create;Bitmap:=TBitmap.Create;tryLoadImage(BitTemp1, cFile);//载入图片BitTemp2.Width := self.Width;BitTemp2.Height := self.Height;BitTemp2.Canvas.StretchDraw(self.ClientRect, BitTemp1);BitMap.width := Self.width;BitMap.height := Self.height;i:=BitMap.Height;for j:= 1 to i dobeginBitMap.Canvas.CopyRect(Rect(0,j-1,BitMap.Width,j),BitTemp2.Canvas,Rect(0,i-1,BitMap.Width,i));Self.Canvas.Draw(0,j-1,BitMap);Application.ProcessMessages;if Stop then Exit;end;for i:=BitMap.Height downto 1 dobeginBitMap.Canvas.CopyRect(Rect(0,i-1,BitMap.Width,i),BitTemp2.Canvas,Rect(0,i-1,BitMap.Width,i));Self.Canvas.Draw(0,i-1,BitMap);Application.ProcessMessages;if Stop then Exit;end;finallyBitmap.free; //释放位图BitTemp1.free;BitTemp2.Free;end;
end;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
beginclose;
end;procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
beginclose;
end;end.//窗体文件
object Form1: TForm1Left = 237Top = 206Align = alCustomBorderStyle = bsNoneCaption = 'Form1'ClientHeight = 487ClientWidth = 613Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalsePosition = poScreenCenterOnCreate = FormCreateOnDestroy = FormDestroyOnKeyDown = FormKeyDownOnMouseDown = FormMouseDownOnShow = FormShowPixelsPerInch = 96TextHeight = 13object Timer1: TTimerInterval = 2000OnTimer = Timer1TimerLeft = 15Top = 26end
end