人气:
放大
缩小
二维码
赞赏
delphi Memo1自动循环上下滚屏
1.窗体上需要一个Memo1控件和一个Timer1时间控件; --------------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);