Board index » delphi » Scrolling a Richedit

Scrolling a Richedit

Using the TRichedit function FindNext to highlight a user selection, I
notice that the text contents don't scroll so that the highlighted
text is visible in the window (as Notepad and MS Word do). I am
probably missing something really simple (as usual), but is there an
easy way to do this automatically? I find it annoying having to
manualy scroll down to find the highlighted text.

Code sample below:

procedure TForm1.FindDialog1Find(Sender: TObject);
var
SType : TSearchTypes;

begin
SType := [];
if (frMatchCase in TFindDialog(Sender).Options) and
   (frWholeWord in TFindDialog(Sender).Options) then
   SType :=  [stWholeWord, stMatchCase]
else
if (frMatchCase in TFindDialog(Sender).Options) then
   SType :=  [stMatchCase]
else
if (frWholeWord in TFindDialog(Sender).Options) then
   SType :=  [stWholeWord] ;

edtDisplay.SelStart :=
edtDisplay.FindText(TFindDialog(Sender).FindText,startpos,
edtDisplay.GetTextLen,
 SType);
edtDisplay.SelLength := Length(TFindDialog(Sender).FindText);
startpos := edtDisplay.SelStart +
Length(TFindDialog(Sender).FindText);

end;

 

Re:Scrolling a Richedit


In article <36355f23.4082...@newshost.pcug.org.au>, ta...@pcug.org.au (Steve

Quote
Tattersall) writes:
>Using the TRichedit function FindNext to highlight a user selection, I
>notice that the text contents don't scroll so that the highlighted
>text is visible in the window (as Notepad and MS Word do). I am
>probably missing something really simple (as usual), but is there an
>easy way to do this automatically? I find it annoying having to
>manualy scroll down to find the highlighted text.

Use the EM_SCROLLCaret message.

RichEdit1.Perform(EM_SCROLLCARET, 0, 0);

Alan Lloyd
alangll...@aol.com

Other Threads