roll.TitleRoll(F_main);
procedure TTitleRoll.OnTime1;
var
T_Caption: string;
function Tab(Tab_i: Integer): string;
var
T_Str: string;
i: Integer;
begin
for i := 1 to Tab_i do
T_Str := T_Str + ' ';
Result := T_Str;
end;
begin
if Title_CS = 0 then
begin
//M_Form.Custom_Timer1.en
Exit;
end;
if Title_TabL <= Title_LR then //20控制向右移动距离
begin
if Title_TabL = 1 then
begin
if T_Count <> 0 then
begin
T_Count := T_Count - 1;
Exit;
end;
end;
T_Caption := S_Title + Tab(Title_TabL) + S_Version;
M_Form.Caption := T_Caption;
T_Count := 50; //控制滚动一次的间隔时间
Title_TabL := Title_TabL + 1;
end
else
begin
if Title_TabR >= 1 then
begin
T_Caption := S_Title + Tab(Title_TabR) + S_Version;
M_Form.Caption := T_Caption;
Title_TabR := Title_TabR - 1;
end
else
begin
Title_TabL := 1;
Title_TabR := Title_LR; //20控制向左移动距离
Title_CS := Title_CS - 1;
end;
end;
{if (Title_Tab <=1) then
begin
Title_Tab :=20;
T_Count :=25;
end;
if T_Count =0 then
begin
T_Caption :=S_Title + Tab(Title_Tab) + S_Version;
M_Form.Caption :=T_Caption;
Title_Tab :=Title_Tab - 1;
end
else
T_Count :=T_Count - 1; }
end;
procedure TTitleRoll.TitleRoll(MainForm: Tform);
var
Custom_Timer1: TTimer;
AYear: string;
resStream: TResourceStream;
Buf: array[1..100] of Char;
begin
resStream := TResourceStream.Create(HInstance, 'AYear', 'txt'); //从MpImages.res中取年份
try
FillChar(Buf, SizeOf(Buf), Ord(' '));
resStream.Read(Buf, resStream.Size);
AYear := Trim(Buf);
finally
resStream.Free;
end;
M_Form := MainForm;
S_Title := Copy(MainForm.Caption, 1, Pos(AYear, MainForm.Caption) - 1);
S_Version := Copy(MainForm.Caption, Pos(AYear, MainForm.Caption), 10);
Title_TabL := 1;
Title_CS := 6;
Title_TabR := Title_LR;
Custom_Timer1 := TTimer.Create(MainForm);
Custom_Timer1.Enabled := False;
Custom_Timer1.Interval := 200; //控制移动速度
Custom_Timer1.OnTimer := OnTime1;
T_Count := 0;
Custom_Timer1.Enabled := True;
end;