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

#include <vcl.h>
#pragma hdrstop

#include "OnSelectionChange.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: OnSelectionChange
// Event: ComCtrls.TCustomRichEdit.OnSelectionChange

// BeginCode
/*
This example requires a TStatusBar and a TRichEdit.  The
code within the form's OnCreate will take care of sizing the
Rich Edit and setting the OnSelectionChange event to be
handled by RichEdit1SelectionChange (or you can paste the
code directly into the OnSelectionChange event handler.)  As
you type in the Rich Edit control, the current character
location the selection begin and end will display in the
status bar control.
*/
void __fastcall TForm1::RichEdit1SelectionChange(TObject *Sender)
{
  StatusBar1->SimpleText = "  Selection Start: " + IntToStr(RichEdit1->SelStart) +
	  "  Selection End: " + IntToStr(RichEdit1->SelStart + RichEdit1->SelLength);
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  char const *Path = "..\\OVERVIEW.RTF";
  RichEdit1->Lines->LoadFromFile(Path);
  RichEdit1->Align = alClient;
  RichEdit1->OnSelectionChange = RichEdit1SelectionChange;
  StatusBar1->SimplePanel = True;
}
// EndCode
// EndExample: OnSelectionChange
//---------------------------------------------------------------------------
