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

#include <vcl.h>
#pragma hdrstop

#include "TScreenCursor.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TScreenCursor
// Property: Forms.TScreen.Cursor

// BeginCode
/*
Assignments to the Screen object's cursor property are
typically guarded by a try...finally statement to ensure
that normal cursor behavior is restored. Note that the
original cursor is saved and restored.  This allows cursor
changes to be nested without accidentally restoring the
cursor to a hard-coded value prematurely.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;    // Show hourglass cursor 
try
{
  // Do some lengthy operation 
  int I = 0;
  int J = 0;
  int X, Y;
  const magicnumber = 150000000;
  while (I < magicnumber)
  {
    Randomize;
	while (J < magicnumber)
	{
	  Y = Random(J);
	  J++;
	}
	X = Random(I);
	I++;
  }
}
__finally
{
  Screen->Cursor = Save_Cursor; // always restore the cursor
}
}
// EndCode
// EndExample: TScreenCursor
//---------------------------------------------------------------------------
