What Are They?
Here, I present some animation provider classes that you may use with any CWaitingTreeCtrl
-derived class (see article). They're just examples now, they can serve you as starting points to implement much butter animation effects, but they can also be used "as-is" in your little projects.
CProgressFX
This animation provider simply displays a progress bar while populating the tree.
If the total count of items to add is known, it shows a linear progress bar, otherwise it maps the current progress (which would grow indefinitely) into a finite range allowing the bar to be displayed.
CHourglassFX
This animation provider simply displays an animated icon with the well-known hourglass.
Note: I finally found the reason why my animated icons were successfully loaded only when linking to MFC dynamic libraries, and it doesn't have anything to do with MFC. The application I used to produce the animated icon, saved the file specifying the wrong size in the RIFF header. Those extra 8 bytes caused the system to read past the end of file, finding zeroes with dynamic libraries and the standard MFC resources with static libraries. It interpreted the zeroes like an EOF marker and returned successfully, while it didn't like the other bytes of subsequent resources thus returning a failure. The correct value in the RIFF header is the file size minus 8, so I just changed the double-word at offset 4 in the VC++ resource editor and got my icon even in static builds.
Using the Classes
Using animation provider classes is very easy. Suppose you have created your own content provider class: CMyTreeCtrl
. If you want to add one or more animations, you declare a variable as follows:
#include "MyTreeCtrl.h"
#include "ProgressFX.h"
#include "HourglassFX.h"
...
CProgressFX< CHourglassFX< CMyTreeCtrl > > m_ctlMyTree;
And this is the result:
Updates
- 17th October, 2000: Initial public release
- 27th September, 2001: Fixed bug with animated icons
License changed to Artistic License
Conclusion
I hope there's someone who likes these classes and who wants to write his own. You may implement a new animation with an external progress control, or with a user selectable animated cursor, or with a message text that reports remaining items to load (like VS Class View), or everything you can imagine. If you do, it would be nice to see a new article about it. I will appreciate any comment, suggestion or improvement.