Cannot change Cursor to crHourGlass at run-time lazarus / 8-Other ---------------------------------------------------------------------- Stefano · 2006-05-08 13:25 Hello, I cannot change at run-time che Cursor, either using Self.Cursor property, either using Screen.Cursor property. Here there is my code: var   MyCursor: TCursor; begin   MyCursor := Self.Cursor;   Self.Cursor := crHourGlass;   {MyCode}   Self.Cursor := MyCursor; end; I don't receive any error message, but the cursor doesn't change. If I set the Form Cursor Property at design time, it's ok. Could you help me? I use Lazarus 9.1.13 on Windows 2000 Professional. Best regards, Stefano ---------------------------------------------------------------------- Anonymous · 2006-05-19 14:58 I cannot solve my problem yet. A great thanks if someone can help me. Best regards, Stefano ---------------------------------------------------------------------- RudieD · 2006-05-19 16:39 Have you tried a Application.ProcessMessages after you set the cursor ? ---------------------------------------------------------------------- Anonymous · 2006-05-19 20:05 Thanks for your reply, I've tried now, but unfortunately it doesn't work yet. The same code, on Delphi, worked without problems (even without ProcessMessages). Have you any other idea to solve this problem on Lazarus? Thank you very much. Best regards, Stefano ---------------------------------------------------------------------- g-r-g · 2006-05-20 05:52 Quote from: "Stefano"var   MyCursor: TCursor; begin   MyCursor := Self.Cursor;   Self.Cursor := crHourGlass;   {MyCode}   Self.Cursor := MyCursor; end; WinXP, Lazarus 0.9.14 - it's working (sorry for this "code" :oops:): Code: [Select] var   lA: TLabel;   i,j: Integer; begin   MyCursor:=Self.Cursor;   Self.Cursor:=crHourGlass;   for i:=0 to 10 do begin     Application.ProcessMessages;     for j:=0 to 1000000 do begin       Application.ProcessMessages;     end;     lA.Caption:=lA.Caption+'lA ';   end;   Self.Cursor:=MyCursor; end; I think there is a problem with your "{MyCode}". ---------------------------------------------------------------------- felipemdc · 2006-05-21 01:20 Self.Cursor := crHourGlass; {MyCode} Self.Cursor := MyCursor; Did you consider the possibility that {MyCode} is executed so fast that you really have no time to see the new cursor? ---------------------------------------------------------------------- Anonymous · 2006-05-23 22:26 Thanks for your reply, yes, I've considered this case, I have also tried to delete the last line: Self.Cursor := MyCursor, in this case the cursor would had stay = crHourGlass for all the time, but the cursor hasn't changed even this time. {MyCode} is very simple, I load a form (that require a bit of time for charging), in any case here there is all my code: ************************************* procedure TfrmPrincipale.mnuLiqIVAClick(Sender: TObject); var   MyQueryIVA: TfrmQueryIVA;   MyItem: TMenuItem;   N: SmallInt;   MyCursor: TCursor; begin   if Ditta = '' then begin     StartLogIn;     if Ditta = '' then exit; //Wrong login   end;   MyCursor := Self.Cursor;   Self.Cursor := crHourGlass;   N := RetFreeNumber;   MyItem := TMenuItem.Create(nil);   MyItem.Name := 'mnuWin' + IntToStr(N);   MyItem.Caption := IntToStr(N) + ' MyCaption';   MyItem.GroupIndex := 1;   MyItem.OnClick := mnuWindow.OnClick;   mnuWindow.Insert((N+nWinItems-1), MyItem);   MyQueryIVA := TfrmQueryIVA.Create(nil);   MyQueryIVA.Caption := MyItem.Caption;   MyQueryIVA.Position := poDefault;   MyQueryIVA.Top := Self.Top + 48;   MyQueryIVA.Left := Self.Left;   MyQueryIVA.Width := Self.Width;   MyQueryIVA.Show;   Self.Cursor := MyCursor; end; ************************************ Thank you very much if you can help me, excuse me for my delay to reply but in this days I had found problems to connect me to the forum. Best regards, Stefano ---------------------------------------------------------------------- felipemdc · 2006-05-24 01:48 I noticed you are using Lazarus 0.9.13 and someone said this works with 0.9.14 Did you try to upgrade to 0.9.14? Also you should try changing your code for this very simple one to have a more clear test: procedure TfrmPrincipale.mnuLiqIVAClick(Sender: TObject); begin Self.Cursor := crHourGlass; end; If this doesn't work, then there are problems. After this you can slowly add your code until it stops working. ---------------------------------------------------------------------- Anonymous · 2006-05-24 09:28 Thanks for your fast reply, I've tried with a very simple code and it works, so I think it isn't a problem of version 9.13 but other. However, I undestrand the problem is in changing the cursor while the new form is charged from the main form. What I want to do is showing the crHourGlass cursor from the moment the user click the item in the main menu, until the selected form is really showed. Aftere a lot of trial, I can say that: 1) If I use the Self.Cursor property (Self is the main form of the program), the Cursor starts changing only when the the secondary form is showed (but not from the main form menu's user click); Application.ProcessMessages unfortunately doesn't solve this problem; 2) If I use the SecondaryForm.Cursor property, nothing happens, I don't know why; 3) If I use the Screen.Cursor property, nothing happens and this is very strange. I have no idea for solve this problem. Have you some advice to help me? Thank you very very much. Best regards, Stefano ---------------------------------------------------------------------- Anonymous · 2006-05-24 14:41 Quote from: "Anonymous" 3) If I use the Screen.Cursor property, nothing happens and this is very strange. same for me. Windows 98, Lazarus 0.9.14 Regards, Bernd. ---------------------------------------------------------------------- Anonymous · 2006-05-26 21:01 I've looked at the Lazarus Bugtracker and, for the Screen.Cursor problem, I've found it: http://www.freepascal.org/mantis/view.php?id=1666 However, I've found no Bugtracker for my Form.Cursor problem. If someone has an idea for changing the cursor during the time necessary for showing the form, I will be grateful. Else I wait the Screen.Cursor bug will be resolved. In any case a great thanks to all who have replied to this topic, and to all the Lazarus's staff, I appreciate Lazarus very much and I'm satisfaied to have leave Delphi for Lazarus. Best regards and sorry for my bad English, Stefano ---------------------------------------------------------------------- g-r-g · 2006-05-27 11:09 Quote from: "Anonymous"2) If I use the SecondaryForm.Cursor property, nothing happens, I don't know why; Try something like this: Code: [Select]procedure TfrmMain.MenuItemFrmSecondaryClick(Sender: TObject); var   i: Integer; begin   FrmSecondary.Cursor:=crHourGlass;   for i:=0 to FrmSecondary.ControlCount-1 do     FrmSecondary.Controls[i].Cursor:=crHourGlass;   FrmSecondary.ShowModal; end;