Mega Code Archive

 
Categories / Delphi / Examples
 

Scrolling a RichEdit

Title: Scrolling a RichEdit Question: How do I scroll my TRichEdit to the end? Answer: There are a number of solutions on how to scroll the richedit box including: ---DO NOT USE THIS EXAMPLE - SEE BELOW INSTEAD--- with MainFrm.RichEdit1 do begin perform (WM_VSCROLL, SB_BOTTOM, 0); perform (WM_VSCROLL, SB_PAGEUP, 0); end; ------------------------------------------------- The above example works fine in 9x and NT4, but it does not work at all in windows 2000, so avoid it all costs. A solution which will work in any version of windows is: with MainFrm.RichEdit1 do begin SelStart := Length(Text); Perform(EM_SCROLLCARET, 0, 0); end; Please, if you are using the first example, change it, in case you ever upgrade. This caused a lot of headaches for me, when users of my programs changed OS, and I had not. Code example works great with D5 (and probably all others) and w2k/9x and NT4.