如何让MEMO里的内容实现循环滚动。

ymhf19373200 2003-10-17 09:11:13
如何让MEMO里的内容实现循环滚动。而不是,自动滚屏一次后再重新滚动。
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
wdir 2003-10-22
  • 打赏
  • 举报
回复
发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.

lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.

If the message is sent to a single-line edit control, the return value is FALSE.

本内容可以在MSDN中找到(关键字 EM_LINESCROLL)


———————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂       
┃迎|◥论坛助手◤|用┃       
┗━☆━━◇━━━☆┛      
wdir 2003-10-22
  • 打赏
  • 举报
回复
发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.

lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.

If the message is sent to a single-line edit control, the return value is FALSE.

本内容可以在MSDN中找到(关键字 EM_LINESCROLL)


———————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂       
┃迎|◥论坛助手◤|用┃       
┗━☆━━◇━━━☆┛      
wdir 2003-10-22
  • 打赏
  • 举报
回复
发送EM_LINESCROLL消息给Memo
EM_LINESCROLL消息可以滚动多行的编辑空间Memo和richEdit
要发送这个消息,使用以下参数调用SendMessage()。
SendMessage(
hWnd:HWND; // handle to destination window
EM_LINESCROLL; //message to send
wParam:Integer;// horizontal scroll increment(垂直滚动)
lParam:Integer // vertical scroll increment(水平滚动)
)
参数
wParam
TMemo: Specifies the number of characters to scroll horizontally.
Rich edit controls: This parameter is not used; it must be zero.

lParam
Specifies the number of lines to scroll vertically.
Return Values
If the message is sent to a multiline edit control, the return value is TRUE.

If the message is sent to a single-line edit control, the return value is FALSE.

本内容可以在MSDN中找到(关键字 EM_LINESCROLL)


———————————
┏━★━━◆━━★━┓
♂欢|◢CSDN◣|使♂       
┃迎|◥论坛助手◤|用┃       
┗━☆━━◇━━━☆┛      
chw_csdn_chw 2003-10-19
  • 打赏
  • 举报
回复
忘了说了,button1是我测试用的,你直接单击button2就行
chw_csdn_chw 2003-10-19
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
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);
var
i:integer;
begin
for i:=0 to 10 do begin
self.Memo1.Lines.Add('aaaaaaaaaaaaaaaaaaaaaaaaa') ;
self.Memo1.Lines.Add('bbbbbbbbbbbbbbbbbbbbbbbbb')
end;
self.Memo1.Enabled:=false;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
//getscrollpos(self.Memo1.Handle,SB_VERT));
i:=0 ;
while i<=self.Memo1.Lines.Count-1 do begin
setscrollpos(self.Memo1.Handle,SB_VERT,i,false);
if i=self.Memo1.Lines.Count-1 then i:=0;
end;

end;


procedure TForm1.Button2Click(Sender: TObject);
var
aa:TRect;
i,j:integer;

begin
aa.Left:=self.Memo1.Left;aa.Right:=self.Memo1.Left+self.Memo1.Width;
aa.Top:=self.Memo1.Top;aa.Bottom:=self.Memo1.Top+self.Memo1.Height;
i:=0 ;j:=-1;
while i<=self.Memo1.Height-1 do begin
setscrollpos(self.Memo1.Handle,SB_VERT,j,true);
ScrollWindow(self.Memo1.Handle,0,-1,nil,nil);
UpdateWindow(self.Memo1.Handle);
// self.Memo1.Refresh;
// self.Memo1.Realign;
if i=self.Memo1.Height-1 then begin
i:=0;
j:=(-1)*j;
end;
sleep(500);
application.ProcessMessages;
end;

end;

end.

效果虽然不太理想,但或许对你有帮助

jackie168 2003-10-17
  • 打赏
  • 举报
回复
用timer控件.....
oicqluck 2003-10-17
  • 打赏
  • 举报
回复
那要用到定时器,和判断多少行,然后编程实现!

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧