procedure TForm1.Timer1Timer(Sender: TObject);
begin
case iDisplayType of
tdmStraight: begin
Caption := Copy(sCaption, 0, Length(Caption) + 1);
if Length(Caption) = Length(sCaption) then begin
iDisplayType := tdmBlink;
Timer1.Interval := 500;
Sleep(1500);
end;
end;
tdmBlink: begin
if Caption <> '' then Caption := ''
else Caption := sCaption;
Dec(iBlinkCnt);
if iBlinkCnt = 0 then begin
iBlinkCnt := 6;
iDisplayType := tdmForward;
Timer1.Interval := 200;
Sleep(1500);
end;
end;
tdmForward: begin
Caption := Copy(sCaption, 0, Length(Caption) - 1);
if Length(Caption) = 0 then begin
iDisplayType := tdmStraight;
Sleep(1500);
end;
end;
end;
end;
타이머 돌리면서 일정 문자열을 잘라서 보여주는거죠.
<!--CodeS-->
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TStrDisplayMode = (tdmStraight,tdmBlink,tdmForward);
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
sCaption: String;
iDisplayType: TStrDisplayMode;
iBlinkCnt: Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
sCaption := 'Hellow World!! 2008-04-14';
Caption := '';
iBlinkCnt := 6;
iDisplayType := tdmStraight;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
case iDisplayType of
tdmStraight: begin
Caption := Copy(sCaption, 0, Length(Caption) + 1);
if Length(Caption) = Length(sCaption) then begin
iDisplayType := tdmBlink;
Timer1.Interval := 500;
Sleep(1500);
end;
end;
tdmBlink: begin
if Caption <> '' then Caption := ''
else Caption := sCaption;
Dec(iBlinkCnt);
if iBlinkCnt = 0 then begin
iBlinkCnt := 6;
iDisplayType := tdmForward;
Timer1.Interval := 200;
Sleep(1500);
end;
end;
tdmForward: begin
Caption := Copy(sCaption, 0, Length(Caption) - 1);
if Length(Caption) = 0 then begin
iDisplayType := tdmStraight;
Sleep(1500);
end;
end;
end;
end;
end.
<!--CodeE-->