Author: Jonas Bilinkevicius
How does one position a Rich Edit control to a specific top index (e.g.
Sendmessage(lbhandle, LB_SETTOPINDEX, 100, 0 works for list boxes, but is ignored
by rich edits)?
Answer:
1 var2 firstline: Integer = 0;
3 4 procedure TForm1.Button2Click(Sender: TObject);
5 begin6 {record current first line}7 firstline := richedit1.perform(EM_GETFIRSTVISIBLELINE, 0, 0);
8 end;
9 10 procedure TForm1.Button3Click(Sender: TObject);
11 begin12 {Scroll back to recorded position}13 with richedit1 do14 perform(em_linescroll, 0, firstline - perform(EM_GETFIRSTVISIBLELINE, 0, 0));
15 end;