转贴自WWW.csdn.net
Lin提供了如下回答, 请您查阅和评估:
---------------------------------------------------------------------------
我连Timer也省了:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
ListBox1: TListBox;
RadioGroup1: TRadioGroup;
Memo2: TMemo;
RadioGroup2: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel3.Left := Panel1.ClientWidth;
Panel3.Top := 0;
end;
procedure TForm1.Button1Click(Sender: TObject);
var nLoop: Integer;
begin
Panel3.Visible := True;
Panel3.BringToFront;
while Panel3.Left > 0 do
begin
Panel2.Left := Panel2.Left + 4;
Panel3.Left := Panel3.Left - 4;
Application.ProcessMessages;
end;
if Panel3.Left < 0 then Panel3.Left := 0;
Panel2.Visible := False;
Button1.Enabled := False;
Button2.Enabled := True;
end;
procedure TForm1.Button2Click(Sender: TObject);
var nLoop: Integer;
begin
Panel2.Visible := True;
Panel2.BringToFront;
while Panel2.Left > 0 do
begin
Panel3.Left := Panel3.Left + 4;
Panel2.Left := Panel2.Left - 4;
Application.ProcessMessages;
end;
if Panel2.Left < 0 then Panel2.Left := 0;
Panel3.Visible := False;
Button1.Enabled := True;
Button2.Enabled := False;
end;
end.