1 在pagedown 过程中判断 第一可视行是否变化即可!!
procedure TForm1.Button8Click(Sender: TObject);
var
n,m:integer;
begin
n:=-1;
while true do begin
RichEdit1.perform(WM_VSCROLL, SB_PAGEDOWN, 0);
m:=RichEdit1.perform(EM_GETFIRSTVISIBLELINE,0,0 );
if m=n then break; //已经到最后!!否则死循环 //就在这里知道!!!!!
n:=m;
end;
end;
//注:这一方法会导致最后一行是不可见的。
2 可能无法实现,因为无法改变选中文本的背景色。以下是
TTextAttributes.Color的说明:“选中文本的背景色是由RichEdit.color决定的”
Description
Use color to indicate the color of the actual characters. the background color is a property of the rich edit control that uses the TTextAttributes object, and should be set by the Color property of the rich edit control.
如果直接想移到头、尾,可用以下方法:
procedure TForm1.Button6Click(Sender: TObject);
begin //移到头上
RichEdit1.SetFocus ;
keybd_event(vk_Control,0,0,0);
keybd_event(VK_HOME,0,0,0);
keybd_event(VK_HOME,0,KEYEVENTF_KEYUP,0);
keybd_event(vk_control,0,KEYEVENTF_KEYUP,0);
end;
procedure TForm1.Button7Click(Sender: TObject);
begin //移到末尾
RichEdit1.SetFocus ;
keybd_event(vk_Control,0,0,0);
keybd_event(VK_END,0,0,0);
keybd_event(VK_END,0,KEYEVENTF_KEYUP,0);
keybd_event(vk_control,0,KEYEVENTF_KEYUP,0);
end;