Re: Finding text in Delphi memoPosted by WAllison on August 29, 2003 at 17:34:15: In Reply to: Finding... posted by Joey on August 23, 2003 at 21:52:22: : I have a Delphi memo box and i want it so that say through out the paragraph it finds a text, say "hello" .How do i make it so it highlights that word and how do i make it so it finds thats word? This way is much more useful coz u can specify where to start searching from /up/down etc var i: integer; SearchOptions: TStringSearchOptions; Buffer, P: PChar; Size: Word; begin SearchOptions := SearchOptions + [soDown]; SearchOptions := SearchOptions - [soMatchCase]; SearchOptions := SearchOptions - [soWholeWord]; Size := Memo1.GetTextLen; Buffer := StrAlloc(Size + 1); try Memo1.GetTextBuf(Buffer, Size+1); P := SearchBuf(Buffer,Size,0,0,SearchEdit.Text,SearchOptions); If P nil then begin ListBox1.Items.Add('SearchBuf(Pointer) found match.'); Memo1.SelStart := P - Buffer; Memo1.SelLength := Length(SearchEdit.Text); end; finally StrDispose(Buffer); end;
[ DelphiLand: free Delphi source code, tips, tutorials ] |
|