本文整理自网络,侵删。
DELPHI Memo1自动循环上下滚屏
--------------Start--------------------
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Memo1.Perform(EM_SCROLL,SB_LINEDOWN,0)=0 then
begin
Memo1.Perform(WM_VSCROLL,SB_TOP,0);
end
else
begin
SendMessage(Memo1.Handle,WM_VSCROLL,SB_LINEDOWN,0);
end;
end;
--------------End--------------------
---希望对做屏幕滚动的朋友,有实际的使用价值.
// 执行到底 SendMessage(Memo1.Handle, EM_SCROLL, SB_BOTTOM, 0);
//一步一步往下走 SendMessage(Memo1.Handle,WM_VSCROLL,SB_LINEDOWN,0);
// 往下走 SendMessage(Memo1.Handle,EM_SCROLL,SB_PAGEDOWN,0);
if Memo1.Perform(EM_SCROLL, SB_LINEDOWN, 0)=0 then//下滚
button2.Enable := False;
if Memo1.Perform(EM_SCROLL, SB_LINEUP, 0)=0 then//上滚
button1.Enable := False;
如何编程使Memo的滚动条滚到行首?
发送消息:
WPARAM para = MAKELONG(SB_THUMBPOSITION,0);//将滚动条移动到0
SendMessage(Memo1->Handle,WM_VSCROLL,para,0);
Memo1->Perform(EM_SCROLL, SB_TOP, 0); //第一行
Memo1->Perform(EM_SCROLLCARET,0,0); //自动滚动到最后一行
改进一下:
Memo1->Lines->BeginUpdate();
Memo1->Perform(WM_VSCROLL,SB_TOP,0); //先回到顶部
for(int i=0; i<1500; ++i) //向下滚1500行
Memo1->Perform(WM_VSCROLL,SB_LINEDOWN,0);
Memo1->Lines->EndUpdate();
移到指定位置,发送消息 吧
WPARAM para = MAKELONG(SB_THUMBPOSITION,50);//将滚动条移动到50 Position
//具体参数请看win32帮助有关于WM_VSCROLL的帮助
// Memo1->Perform(WM_VSCROLL,para,0); //这个也行
SendMessage(Memo1->Handle,WM_VSCROLL,para,0);
相关阅读 >>
Delphi xe5 使用 android 内置函数几个小测试
Delphi ifileoperation替换shfileoperation
Delphi 将image组件的图片保存为jpg格式图片方法
Delphi 如何确定access数据库中存在某一个已知名的表
更多相关阅读请进入《Delphi》频道 >>