化两分钟写出来的:var
x,x1:PRect;
begin
new(x);
new(x1);
x^ := Memo1.ClientRect;
x1^ := Memo1.ClientRect;
ScrollWindow(Memo1.Handle,0,-1,x,x1);
end;但是只能滚动,不能更新,可能有更好的方法,ScrollWindowEx、ScrollDC...
没有时间试了
x,x1:PRect;
begin
new(x);
new(x1);
x^ := Memo1.ClientRect;
x1^ := Memo1.ClientRect;
ScrollWindow(Memo1.Handle,0,-1,x,x1);
end;但是只能滚动,不能更新,可能有更好的方法,ScrollWindowEx、ScrollDC...
没有时间试了
解决方案 »
- VC中的!非 和 && || 符号对应 delphi 中该如何写?
- 关于怎么样定时将windows的服务启动?------再线等......
- 只要您来您就不会后悔。
- 我的CORBA哪去了?
- Delphi7 Access violation at address问题
- 使用TChart画K线图,个别股票的线条不是曲线,散分!!!急!!!
- 取文件图标的问题!!! 高手请进……
- 怎么打开*.scm的文件(在线等待)?
- 请问: Delphi中有在整个硬盘中查找指定文件或者目录的函数吗?不会又要递归搜索吧?!
- 请高手指点在Delphi中如何使用指针。
- 数据库服务器与应用程序服务器,谁瘦谁胖?
- 请问关于Tinifile的详细介绍。。。小弟E文太差。。谢谢(63分)
好想效果不是很好呀?不知道什么原因,它里面有的行乱位了??另外,他不能当滚到最后一行的时候有自动从第一行开始,怎么实现?
唉,你把源码贴出来不就可以了?成功就结账了
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label1.Top := Label1.Top - 1;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Top := 1;
Label1.Left := 1;
Label1.AutoSize := False;
Label1.Width := Memo1.Width - 2;
Label1.Height := Memo1.Height * 2;
Label1.Parent := Memo1;
Timer1.Interval := 10;
CheckBox1.Checked := False;
CheckBox1Click(CheckBox1);
end;procedure TForm1.CheckBox1Click(Sender: TObject);
begin
Label1.Top := 1;
Timer1.Enabled := TCheckBox(Sender).Checked;
Label1.Visible := TCheckBox(Sender).Checked;
Label1.Caption := Memo1.Text;
Label1.WordWrap := Memo1.WordWrap;
end;
这样不行吧???
不简单,怎么和我想到一起去了。我以为只有我才会想到这种方法的。
你的方法确实好,但是能提供一点源代码嘛?不能的话,我还是不知道,呵呵
你的方法确实好,但是能提供一点源代码嘛?不能的话,我还是不知道,呵呵
你的方法确实好,但是能提供一点源代码嘛?不能的话,我还是不知道,呵呵
在OnTimer事件中,写如下代码:(我随手写的,可能有错,你自己调试一下吧)PaintBox1.Canvas.Brush.Color := clwhite;
PaintBox1.Canvas.FillRect(Rect(0,0,PaintBox1.Width, PaintBox1.Height));
PaintBox1.Canvas.Font.Color := clBlack;
PaintBox1.Canvas.Font.Name:='宋体';
PaintBox1.Canvas.Font.Size:=10;
PaintBox1.Canvas.Brush.Style := bsClear;
PaintBox1.Canvas.TextOut(10,y,'这是一个测试'); //y为一个全局变量
dec(y);
我原来是用Label来实现平滑移动,但用它没法显示较大文本,后来也曾使用memo,但移动起来太"硬"了,一点都不平滑很不舒服.如果有高人能相告定当感激不尽.
希望你不吝赐教!!将源吗尽贴一下,旅人在这里谢过了!!!
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Y:integer;
implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
y:=paintbox1.Height;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
PaintBox1.Canvas.Font.Color := clBlue;
PaintBox1.Canvas.TextOut(50,y,'这是平滑滚屏示例');
PaintBox1.Canvas.Font.Color := clBlack;
PaintBox1.Canvas.TextOut(60,y+PaintBox1.Canvas.Font.Size+8,'效果还不错吧');
dec(y);
if y<-(PaintBox1.Canvas.Font.Size+8)*2 then y:=paintbox1.Height;
end;procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Font.Name:='宋体';
PaintBox1.Canvas.Font.Size:=10;
PaintBox1.Canvas.Brush.Color := clwhite;
PaintBox1.Canvas.FillRect(Rect(0,0,PaintBox1.Width, PaintBox1.Height));
end;
end.
//main.dfm
object Form1: TForm1
Left = 209
Top = 142
Width = 214
Height = 202
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object PaintBox1: TPaintBox
Left = 0
Top = 0
Width = 206
Height = 175
Align = alClient
OnPaint = PaintBox1Paint
end
object Timer1: TTimer
Interval = 50
OnTimer = Timer1Timer
Left = 152
Top = 128
end
end
谢谢你的源吗,平滑滚屏我已经实现,但是按照你的做法的话,
paintbox会闪烁不停,请问你在你的WinPan里面是怎么实现的??就是让屏幕不闪烁!!
谢谢
能把你的原码贴出来吗?
var
X,Y: Integer;//Y为字体输出的纵坐标,X为控制Y的值的变量procedure TForm1.FormCreate(Sender: TObject);
begin
Y:=PaintBox1.Height;
X:=Y;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);//从文件中读取内容到Memo
end;procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
PaintBox1.Canvas.Brush.Color := clwhite;
PaintBox1.Canvas.FillRect(Rect(0,0,PaintBox1.Width, PaintBox1.Height));
PaintBox1.Canvas.Font.Color := clBlack;
PaintBox1.Canvas.Font.Name:='宋体';
PaintBox1.Canvas.Font.Size:=10;
end;procedure TForm1.Timer1Timer(Sender: TObject);
var
I:Integer;
begin
for I:=0 to Memo1.Lines.Count do
begin
PaintBox1.Canvas.TextOut(10,Y,Memo1.Lines[I]); //y为一个全局变量
Y:=Y+PaintBox1.Canvas.Font.Size+6; //6为行间距,自己可以设定
end;
dec(X);
Y:=X-1; //每次timer事件开始都对Y-1
if Y<-(Memo1.Lines.Count)*(PaintBox1.Canvas.Font.Size+2) then //循环滚动
begin
Y:=PaintBox1.Height;
X:=Y;
end;
end;
源代码贴出来了,你们看看吧
我的确实有闪烁,代码跟你的一样吧,你看了上面的代码嘛?另外,你是怎么处理他那里面的文字格式的比如说:Memo里面第一行居中,还有段落等格式的?就是要他跟Memo里面现实的格式一样