//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop

#include "MainFrm.h"
#include "Demo7Frm.h"
//---------------------------------------------------------------------------
#pragma link "RVEdit"
#pragma link "RichView"
#pragma link "RVScroll"
#pragma resource "*.dfm"

/*
 See advanced versions of this demo on the forum:
 http://www.trichview.com/forums/viewtopic.php?t=57
*/


TfrmDemo7 *frmDemo7;
//---------------------------------------------------------------------------
__fastcall TfrmDemo7::TfrmDemo7(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo7::FormCreate(TObject *Sender)
{
  rve->Clear();
  rve->LoadText(ExtractFilePath(Application->ExeName)+"MainFrm.cpp",0,0, false);
  rve->Format();
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo7::FormKeyDown(TObject *Sender, WORD &Key,
    TShiftState Shift)
{
  if (Key==VK_ESCAPE)
    Close();    
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo7::btnMarkClick(TObject *Sender)
{
  rve->SetSelectionBounds(0,rve->GetOffsBeforeItem(0),0,rve->GetOffsBeforeItem(0));
  while (rve->SearchText(txt->Text, TRVESearchOptions()<<rvseoDown))
    rve->ApplyTextStyle(sncomMarked);
// Note: every call of ApplyTextStyle reformats affected paragraphs
}
//---------------------------------------------------------------------------
void __fastcall TfrmDemo7::btnUnmarkClick(TObject *Sender)
{
  rve->SelectAll();
  rve->ApplyTextStyle(sncomNormal);
  rve->Deselect();
  rve->Refresh();
}
//---------------------------------------------------------------------------