Screen cursor

Giganews Newsgroups
Subject:Screen cursor
Posted by: Enquiring Mind (Enquiring.Mind@nospam.btopenworld.com)
Date:Fri, 30 May 2008

Hi,

Consider the following procedure. The RefreshTimeRecords call within the
try..finally block is potentially lengthy, so I want to display the
hourglass cursor while it runs. RefreshTimeRecords connects to a database
and extracts some data.

procedure TFormTimesheet.ActionRefreshExecute(Sender: TObject);
begin
  Screen.Cursor:= crHourglass;
  try
    RefreshTimeRecords(FTimeRecords);
    DataToControls;
  finally
    Screen.Cursor:= crDefault;
  end;
end;

However the procedure doesn't behave as intended. The Screen.Cursor, which
is set to crHourglass at the start of the lengthy routine, does not retain
the setting until the statement where it is reset to crDefault.  When the
action is executed the cursor jumps back to crDefault almost immediately,
well before the method RefreshTimeRecords has finished running. Neither
RefreshTimeRecords nor DataToControls make any changes to Screen.Cursor.

Any idea what could be causing the cursor to return to its default value
before the intended time?

TIA.

EM

Replies