Lazarus

Programming => General => Topic started by: Marion on November 27, 2022, 12:39:14 am

Title: Trying to change the cursor on Screen not happening before loop
Post by: Marion 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.  
Title: Re: Trying to change the cursor on Screen not happening before loop
Post by: jamie on November 27, 2022, 12:42:05 am
most likely you need to call the Application.ProcessMessages on your loop.
Title: Re: Trying to change the cursor on Screen not happening before loop
Post by: Marion 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.
Title: Re: Trying to change the cursor on Screen not happening before loop
Post by: ASerge 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