Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to draw the default animated cursor (hourglass in XP, circle since vista) on a form.

Theoretically, this is no problem using LoadCursor(NULL, IDC_WAIT) and DrawIconEx with the special parameter istepIfAniCur.
My problem is: How to determine the number of frames of such a system cursor (when to restart?).
The ICONINFOEX structure does not unveil this information.
I think the ICONDIR structure - the first bytes in the raw memory dump of the resource - does contain the number of images. But: How to get the raw resource data for a system / stock object.
FindResource(NULL, MAKEINTRESOURCE(IDC_WAIT), RT_CURSOR) does not help.

I hope, some MFC/Win32-Resource expert has some idea. Thanks in advance !

For all which are wondering why I sometimes refer to icons: In Win32, internally a cursor is only a special kind of icon. A icon resource (or file) contains multiple images, each for a distinct resolution/color depth. An animated cursor contains multiple "frames" which must be displayed cyclically ("thumb cinema").


PS: Why i would do this ? We have a special control displaying tasks (nested) and progresses, and we like to indicate background activity. Of course a marquee progress control could also serve as a "wait indicator", but this simple problem is just challenging me ;-)
Posted

1 solution

As a hack, you can try drawing with DrawIconEx, increasing the cursor step until it returns false.
The step prior to the failed attempt is the maximum number of frames of the cursor.
 
Share this answer
 
Comments
OriginalGriff 1-Jan-22 15:50pm    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 10 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more!
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.
Nicke Manarin 17-Sep-22 20:14pm    
I understand that the question is old, but the problem is still there (I found this question because I was searching for a solution).
I answered so that others (not the original person who posted the question) could know how to solve this issue.
I don't care about internet points :)
OriginalGriff 18-Sep-22 0:42am    
I can understand that you don't care about the points - neither do I - but you have to understand what your actions look like to others. Some people here are very attached to their point total (having worked hard to get it) and anyone who appears to be trying to play the system and get points unfairly is going to be targeted as a cheat - and kicked off the site by the community as a result. You'd be surprised how many we get trying to game the system and get an unfair rep one way or another!

So take this as a friendly warning: if you only answer old questions then you leave your actions open to interpretation - and some people will assume the worst!

I didn't start the process of kicking you off - you're still here 9 months later - but somebody will unless you are careful! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900