I've used the code below to search a memo and it has always worked as it should.
When I use it to search a rich text it works in as much as it finds all instances of the searched for text but doesn't programatically move the scrollbar down to show instances on the next page down as it should
do
Hope that I've made things clear
Thanks
Blod
- Code: Select all
var Buffer, Pos, tPointer : PChar;
BuffLength : Word;
line:integer;
begin
With Sender as TFindDialog do
begin
GetMem(tPointer, Length(FindText) + 1);
StrPCopy(tPointer, FindText);
BuffLength:= keeprtf.GetTextLen + 1;
GetMem(Buffer,BuffLength);
keeprtf.GetTextBuf(Buffer,BuffLength);
Pos:= Buffer + keeprtf.SelStart + keeprtf.SelLength;
Pos:= StrPos(Pos, tPointer);
if Pos = NIL then MessageBeep(0)
else
begin
keeprtf.SelStart:= Pos - Buffer;
keeprtf.SelLength:= Length(FindText);
end;
FreeMem(tPointer, Length(FindText) + 1);
FreeMem(Buffer,BuffLength);
keeprtf.SetFocus; //This line highlight the found text
end;
end;