怎样实现在窗体中显示滚动字符?效果就象flash!

解决方案 »

  1.   

    需要在窗体上放一个TIMER控件:
    Procedure  tform1.formcreate(sender:tobject);
      begin// 设置字幕
        label1.caption:='设计: 王三'+#13+#13
                         +‘编码: 李二’+#13+#13
                          +‘美工: 来哥’+#13+#13;
      end;    
    在TIMER的事件中添加
     Procedure tform1.ttimer1time(sender: tobject);
      begin
         label1.top:=label1.top-1;
         if (label1.top<-label1.width-30) then
               label1.top:=panel.height;  //label的父类;
       end;
    可参照修改!!!
      

  2.   

    滚动的文字和图片,给你全部的源码。有点闪,处理一下
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      ExtCtrls;type
      TForm1 = class(TForm)
        Timer1: TTimer;
        Image1: TImage;
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      x,tt,w,h:integer;
      Pic:Trect;
      Map:Tbitmap;
    implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
      x:=image1.Height+20;
      tt:=x+80;
    //  form1.Repaint;
      image1.Canvas.brush.Color:=clgreen;
      pic:=rect(0,0,image1.width,image1.height);
      image1.Canvas.fillrect(pic);
      map:=tbitmap.create;
      map.loadfromfile('1.bmp');
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      x:=x-1;
      tt:=tt-1;
      if x<-200 then
         begin
         x:=image1.Height+20;
         tt:=x+80;
         end;
      image1.Canvas.Font.Size:=18;
      image1.Canvas.Font.Color:=$1200ffff;
      image1.Canvas.TextOut(10,x,'OK 字 幕 移 动 演 示');  image1.Canvas.Font.Size:=20;
      image1.Canvas.Font.Color:=$120000ff;
      image1.Canvas.TextOut(20,x+50,'字 体 变 色 效 果 演示');  h:=image1.canvas.textheight('字体变色效果演 示');
      w:=image1.Canvas.TextWidth('字体变色效果演示');  image1.Canvas.Pen.Color:=clGreen;
      image1.canvas.moveto(20,h+x+50-2);
      image1.canvas.LineTo(20+w,h+x+50-2);
      pic.Topleft.x:=30;
      pic.topleft.y:=tt;
      pic.Bottomright.x:=pic.TopLeft.x+100;
      pic.Bottomright.y:=pic.TopLeft.y+80;
      image1.canvas.StretchDraw(pic,map);
      image1.Canvas.Pen.color:=clgreen;
      image1.Canvas.LineTo(pic.topleft.x+100,pic.topleft.y+80);
    end;end.