Add an hourglass

Hello,
I’m developing a standalone application (compiled with gcc) with TGMainFrame and TGRootEmbeddedCanvas.
During the computations I would like that the mouse pointer became an hourglass. There isn’t a SetCursor associated with the TGMainFrame and I have a lot of TGRootEmbeddedCanvas activated.
How is possible to do this?
Thank you very much
Best regards
Andrea Bulgarelli

Hi Andrea,

To change the cursor when it is in the canvas area you need the first line, to have the same cursor if the user moves it over GUI frames you need the second line.

   // change cursor to kWatch 
   if (gPad) gPad->GetVirtCanvas()->SetCursor(kWatch);
   gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kWatch));

   // Do something that takes time
 
   // back to pointer cursor
   if (gPad) gPad->GetVirtCanvas()->SetCursor(kPointer);
   gVirtualX->SetCursor(GetId(), gVirtualX->CreateCursor(kPointer));

The available cursors in Root are:

enum ECursor { kBottomLeft, kBottomRight, kTopLeft, kTopRight,
               kBottomSide, kLeftSide, kTopSide, kRightSide,
               kMove, kCross, kArrowHor, kArrowVer, kHand, kRotate,
               kPointer, kArrowRight, kCaret, kWatch };

Best regards, Ilka