最简单的,但要有资源文件。
program LittleBear;
uses
Windows, TransWnd;
{$R *.RES}
var
Action: Integer;
bLeft: Boolean;
sWidth, sHeight: Integer;
procedure AgentOnTimer(hwnd: HWND; idEvent: UINT);
var
sAction: String;
begin
case Action of
1, 2: begin Action := 3; bLeft := not bLeft end;
3: if bLeft then Action := 1 else Action := 2;
end;
if AgentService.Left < sWidth then
AgentService.Left := AgentService.Left + 18
else AgentService.Left := 0;
Case Action of
1: sAction := '1';
2: sAction := '2';
3: sAction := '3';
end;
AgentService.LoadFromResource('B' + sAction);
end;
function Start: Boolean;
begin
Action := 1;
bLeft := True;
with AgentService do
begin
Left := 0;
Top := 300;
Width := 230;
Height := 100;
Result := Run;
MaskColor := $00FFFF; { clYellow }
Interval := 230;
OnTimer := @AgentOnTimer;
TimerEnabled := True;
end;
end;
procedure Wait;
begin
AgentService.GlobalProcessMessages;
end;
begin
sWidth := GetSystemMetrics(SM_CXSCREEN);
sHeight := GetSystemMetrics(SM_CYSCREEN);
if Start then Wait;
end.