unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, jpeg, ExtCtrls;

type
  TForm2 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    RichEdit1: TRichEdit;
    OpenDialog1: TOpenDialog;
    Button3: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
  if (OpenDialog1.Execute) then
  RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm2.Button2Click(Sender: TObject);

var T:integer;
begin

T := Richedit1.FindText(Edit1.Text, 0, length(Richedit1.Text), [stMatchCase]);

  if(T > 0) then
  begin
    Richedit1.HideSelection := false;
    Richedit1.SelStart := Length(Richedit1.Text)-1;
    Richedit1.SelLength := 1;
    Richedit1.Focused;
    Richedit1.SelStart := T;
    Richedit1.SelLength := Length(Edit1.Text);
    Richedit1.Focused;
    Richedit1.HideSelection := true;
  end;
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
Close;
end;

end.
 