问题1、
const
DisplayText = '卷起千堆雪tyn';
var
Done : Boolean;
procedure TForm1.Button2Click(Sender: TObject);
var
I :Integer;
Bitmap :TBitmap;
begin
Bitmap := TBitmap.Create;
Bitmap.Width := Width;
Bitmap.Height := 40;
Bitmap.Canvas.Font.Name := 'Arial Bold';
Bitmap.Canvas.Font.Size := 16;
Bitmap.Canvas.Brush.Color := clSilver;
Bitmap.Canvas.FillRect(Rect(0, 0, Width, 40));
Done := False;
while not Done do begin
for I := -Bitmap.Canvas.TextWidth(DisplayText)
to Pred(Width) do begin
Application.ProcessMessages;
if (Done) then
Break;
Sleep(10);
Bitmap.Canvas.Font.Color := clGray;
Bitmap.Canvas.Brush.Style := bsClear;
Bitmap.Canvas.TextOut(2, 12, DisplayText);
Bitmap.Canvas.Font.Color := clBlack;
Bitmap.Canvas.Brush.Style := bsClear;
Bitmap.Canvas.TextOut(0, 10, DisplayText);
Canvas.Draw(I, 0, Bitmap);
end;
end;
Bitmap.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Done := True;
end;
问题2、
var
Draw :Boolean;
Sp,Ep :TPoint;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Draw :=False;
DoubleBuffered :=True; //在D6下加上这句
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Draw :=True;
Sp :=Point(x,y);
Ep :=Sp;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if Draw then
begin
with Image1.Canvas do
begin
Pen.Mode :=pmNotXor;
Brush.Style :=bsClear;
Rectangle(Sp.x,Sp.y,Ep.x,Ep.y);
Ep :=Point(x,y);
Rectangle(Sp.x,Sp.y,Ep.x,Ep.y);
end;
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Draw then
begin
with Image1.Canvas do
begin
Rectangle(Sp.x,Sp.y,Ep.x,Ep.y);
Pen.Mode :=pmCopy;
Rectangle(Sp.x,Sp.y,x,y);
end;
end;
Draw :=False;
end;