How to position a TRichEdit control to a specific top index (Views: 710)
Problem/Question/Abstract: 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: var firstline: Integer = 0; procedure TForm1.Button2Click(Sender: TObject); begin {record current first line} firstline := richedit1.perform(EM_GETFIRSTVISIBLELINE, 0, 0); end; procedure TForm1.Button3Click(Sender: TObject); begin {Scroll back to recorded position} with richedit1 do perform(em_linescroll, 0, firstline - perform(EM_GETFIRSTVISIBLELINE, 0, 0)); end; |