用DELPHI制作滚动文字窗口!用TABEL制作全屏的文字滚动效果,在文字多时会闪烁得很厉害,请问如何改实现GDI直接画到窗体上,达到像素级的滚屏效果!
请问各位有这方面的范例吗?
谢谢!

解决方案 »

  1.   

    Timer时间定长一点,应该不怎么闪烁。也可以用Image.Canvas.TextOut来画
      

  2.   

    用TPanel,然后把Panel.DoubleBuffer设为True
      

  3.   

    像素级就要用Image.Canvas.TextOut
      

  4.   

    时间设长了,治标不治本!多少还会闪烁的!用文本显示,字体也不饱满!
    那请问如何用Image.Canvas.TextOut
    能实现GDI输出显示吗?最好能给个范例谢谢!
      

  5.   

    范例也给我一分吧! [email protected]
      

  6.   

    同意 Linux2001(我想买手提电脑啊!) 的提议!
      

  7.   

    Tcanvas就是delphi封装并简化了传统的windows编程直接使用GDI函数和工具的使用诸如Tform和TGraphic等高级类都有canvas属性
    直接canvas.textout(x,y,'aaaaaa')就行了//x,y为坐标在timer事件中重画就行了,别忘了将以前的画布抹掉clearcanvas()。否则就成花脸了
      

  8.   

    canvas.textout(x,y,'aaaaaa')能正确显示,但不知如何才能与TABEL相配合,我想利用TABEL的自动分行功能显示!
      

  9.   

    我运行clearcanvas();出错!!!
    clearcanvas()如何调用?是否要输入坐标参数!请示范!
      

  10.   

    有网友介绍下个外部控件,网址:http://www.trichview.com/download/
    找到一个文字上升的DEMO文件,漂亮得很,不会闪烁!可惜原程序不知如何运行!老是报错!
    谁教教我!
      

  11.   

    procedure TFrmMain.Create_TextBmp(pParent : TPanel; strFile : String);
    var
      bmpShowText : TBitMap;       //Bmp To Show
      strTemp : String;            //temp string for reading every line
      ReadFile : TextFile;         //Point to open the source text file
      strItems : TStringList;      //itemps of string list to save texts
      rectDraw, rectTemp : TRect;  //total rect for bmp & temp rect for every line
      iyPos, iLineHet : Integer;   //current y Pos to draw one line & line height
      pDC : HDC;                   //Device context of Bmp
      itemp : Integer;             //for for cycle
    begin
      AssignFile(ReadFile, strFile);
      Reset(ReadFile);
      strItems := TStringList.Create;
      with strItems do
        while not eof(ReadFile) do
        begin
          Readln(ReadFile,strTemp);
          add(strTemp);
        end;
      CloseFile(ReadFile); //读取提示文件中的数据到strItems  bmpShowText := TBitMap.Create;  pDC := GetDc(pParent.handle);
      iLineHet := Get_LineHeight(pDC, bmpShowText.Canvas.Font.Height);
      with rectDraw do //rectDraw 矩形坐标(左上x,左下y,右上x,右下y)
      begin
        Top := 0;
        Left := 0;
        Right := pParent.Width;
        Bottom := iLineHet * strItems.Count + Height;//行高*行数+form高度
      end;
      with bmpShowText do
      begin
        Height := rectDraw.Bottom+100;//图片高度
        Width := rectDraw.Right;
        with Canvas do  //canvas 画布
        begin
          FillRect(rectDraw);
          Brush.Style:=bsClear;
          Font.Name := '宋体';
          Font.Size := 10;
        end;
      end;  rectTemp.Right := rectDraw.Right;
      rectTemp.Bottom := rectDraw.Bottom;
      rectTemp.Left := rectDraw.Left;
      iyPos := pParent.Top;  for itemp := 0 to strItems.Count-1 do // 从0到行数  循环生成图片
      begin
        rectTemp.Top := iyPos;
        rectTemp.Bottom := rectTemp.Top + iLineHet;
        //中对齐
        //DrawText(bmpShowText.Canvas.Handle, pChar(strItems[itemp]), -1, rectTemp, Dt_Center or Dt_Top);
        //左对齐
        DrawText(bmpShowText.Canvas.Handle, pChar(strItems[itemp]), -1, rectTemp, Dt_Left or Dt_Top);
        //右对齐
        //DrawText(bmpShowText.Canvas.Handle, pChar(strItems[itemp]), -1, rectTemp, Dt_Right or Dt_Top);
        Inc(iyPos, iLineHet);
      end;
      BitBlt(pDc, 0, 0, pParent.Width, pParent.Height,
        bmpShowText.Canvas.Handle, 0, pParent.Top, srcCopy);  strItems.Free;     //释放串strItems
      bmpShowText.Free;  //释放图片资源
    end;调用参数第一个是用于显示的Panel,第二个是字符文件
    基本上算是Dx,自己看看吧
      

  12.   

    哈,兄弟们,我们用TRICHVIEW解决问题了,不会出现闪烁的现象,程序代码就只有五六行的。
    这个控件还不错
    如果感兴趣,大家到www.51delphi.com去下载一个最新的for d7吧
      

  13.   

    大家感觉一下,很简单
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      rv.TopMargin:=screen.Height;
      rv.BottomMargin:=screen.Height;
      rv.AddNL('我是中国人',1,1);
      rv.LoadText('1.txt',0,0,true);
      rv.VSmallStep := 1;
      rv.Format;
    end;procedure TForm1.Timer1Timer(Sender: TObject);
    begin
       if rv.VScrollPos<>rv.VScrollMax then
         rv.VScrollPos := rv.VScrollPos+1
       else
         rv.VScrollPos := 0;
    end;procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
    begin
      if ord(key)=27 then
        close;
    end;