//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TFindDialogOptions.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  const AnsiString Path = "../overview.rtf";
  RichEdit1->PlainText = False;
  RichEdit1->Lines->LoadFromFile(Path);
  RichEdit1->ScrollBars = ssVertical;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  ReplaceDialog1->Execute();
}
//---------------------------------------------------------------------------
// BeginExample: TFindDialogOptions
// Property: Dialogs.TFindDialog.Options
// Property: Dialogs.TReplaceDialog.ReplaceText

// BeginCode
/*
The following code calls the user-defined routine DoReplace
if the Replace button was clicked, or calls the user-defined
routine DoReplaceAll if the Replace All button was clicked.
Place a TReplaceDialog, a TButton and a TRichEdit in the form.
*/
void __fastcall TForm1::ReplaceDialog1Replace(TObject *Sender)
{
  TReplaceDialog *dlg = dynamic_cast<TReplaceDialog *>(Sender);
  if (dlg->Options.Contains(frReplace))
	DoReplace(dlg->FindText, dlg->ReplaceText);
  else if (dlg->Options.Contains(frReplaceAll))
    DoReplaceAll(dlg->FindText, dlg->ReplaceText);
}

void __fastcall TForm1::DoReplace(AnsiString FindText, AnsiString ReplaceText)
{
  ShowMessage(
	"DoReplace: FindText: " + ReplaceDialog1->FindText +
	" ReplaceText: " + ReplaceDialog1->ReplaceText);
};

void __fastcall TForm1::DoReplaceAll(AnsiString FindText, AnsiString ReplaceText)
{
  ShowMessage(
	"DoReplaceAll: FindText: " + ReplaceDialog1->FindText +
	" ReplaceText: " + ReplaceDialog1->ReplaceText);
};
// EndCode
// EndExample: TFindDialogOptions
//---------------------------------------------------------------------------
