Recent

Author Topic: Trying to change the cursor on Screen not happening before loop  (Read 477 times)

Marion

  • Full Member
  • ***
  • Posts: 122
Trying to change the cursor on Screen not happening before loop
« on: November 27, 2022, 12:39:14 am »
I'm trying to do a basic feature but the cursor doesn't update before the loop start. IF, I comment out the code after the cursor set, then the Screen cursor changes just fine. Am I missing something?

Code: Pascal  [Select][+][-]
  1. Screen.Cursor := crHourGlass;
  2.   t := 0;
  3.   for i := 0 to FProject.Races.Count - 1 do
  4.     begin
  5.       rac := FProject.Races.Objects[i] as TRace;
  6.       rac.GenerateFulleNames;
  7.     end;
  8. Screen.Cursor := crDefault;
  9.  
Thank you,
Marion
(A recovering Windows programmer.)

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: Trying to change the cursor on Screen not happening before loop
« Reply #1 on: November 27, 2022, 12:42:05 am »
most likely you need to call the Application.ProcessMessages on your loop.
The only true wisdom is knowing you know nothing

Marion

  • Full Member
  • ***
  • Posts: 122
Re: Trying to change the cursor on Screen not happening before loop
« Reply #2 on: November 27, 2022, 12:52:04 am »
most likely you need to call the Application.ProcessMessages on your loop.

That did it. Thank you for the quick reply.
Thank you,
Marion
(A recovering Windows programmer.)

ASerge

  • Hero Member
  • *****
  • Posts: 2212
Re: Trying to change the cursor on Screen not happening before loop
« Reply #3 on: November 27, 2022, 10:12:44 am »
That did it. Thank you for the quick reply.
It would also be nice to protect the cursor from exceptions.
Code: Pascal  [Select][+][-]
  1. Screen.Cursor := crHourGlass;
  2. try
  3.   // ...
  4. finally
  5.   Screen.Cursor := crDefault;
  6. end;

 

TinyPortal © 2005-2018