My application is loading list items from a database in the background with a separate thread. During the loading process the user can interact with the application, so I don't want to change the default cursor. Still, to visually signal the loading process, I'd like to display the Windows busy (hourglass, IDC_WAIT) cursor on my form like an animated image. What would be the easiest way to do that? I was thinking of converting to a GIF and displaying in a GIFImage but I'd like to display the default Windows cursor (thus getting the resource from the system dynamically).
Note: I'm using Delphi7.
Just a partial solution: Declare variables
Then load the cursor:
Then draw the current frame in the
OnPainthandler:To animate it, you can use a
TTimerwith this code:To try this, you can just put the variables in a new VCL application's main form class (below
private), put theLoadImagein the form'sOnCreatehandler and theDrawIconExin theOnPainthandler.But if you want to use this in a real app, you'd better create a new custom control with it.
Obviously, you need to replace
FFrameIdxwithFFrameIdx mod FFrameCountorInc(FFrameIdx)withFFrameIdx := Succ(FFrameIdx) mod FFrameCount, whereFFrameCountis the number of frames in the animated cursor.You should also set the timer's
Intervalto match the cursor's frame rate.