procedure TForm1.FindDialog1Find(Sender: TObject); VAR Buff, P, FT : PChar; BuffLen : Word; begin WITH Sender AS TFindDialog DO BEGIN GetMem(FT, Length(FindText) + 1); StrPCopy(FT, FindText); BuffLen := Memo1.GetTextLen + 1; GetMem(Buff, BuffLen); Memo1.GetTextBuf(Buff, BuffLen); P := Buff + Memo1.SelStart + Memo1.SelLength; P := StrPos(P, FT); IF P = NIL THEN MessageBeep(0) ELSE BEGIN Memo1.SelStart := P - Buff; Memo1.SelLength := Length(FindText); END; FreeMem(FT, Length(FindText) + 1); FreeMem(Buff, BuffLen); END; end; procedure TForm1.ReplaceDialog1Replace(Sender: TObject); begin WITH Sender AS TReplaceDialog DO WHILE True DO BEGIN IF Memo1.SelText <> FindText THEN FindDialog1Find(Sender); IF Memo1.SelLength = 0 THEN Break; Memo1.SelText := ReplaceText; IF NOT (frReplaceAll IN Options) THEN Break; END; end; |