Click here to Skip to main content
15,886,673 members
Articles / Desktop Programming / MFC

CProgressFX and CHourglassFX

Rate me:
Please Sign up or sign in to vote.
4.95/5 (22 votes)
26 Sep 2001 176.4K   5.4K   127   11
Two animation provider classes to add animation effects to any CWaitingTreeCtrl-derived class

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.

Sample application

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.

Sample application

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:

C++
#include "MyTreeCtrl.h"

#include "ProgressFX.h"
#include "HourglassFX.h"

...

    CProgressFX< CHourglassFX< CMyTreeCtrl > > m_ctlMyTree; 

And this is the result:

Sample application

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.


Written By
Technical Lead RoboTech srl
Italy Italy
Paolo began programming at the age of 9 with a glorious Olivetti M24 (i8086) and GW-BASIC, then he played a bit with Turbo C, Turbo Pascal and Assembly (using the MS-DOS Debug). Quick BASIC and Visual Basic shortly followed, until he learned C++ in College. He tought himself MFC and Windows programming, along with some DHTML and Javascript.

Always attracted by low-level programming and Assembly, he started to appreciate the joys of templates and STL while working for his Master Thesis. For seven months he was playing with airplanes and automatic control at the Unversity of Illinois at Urbana-Champaign, where he first met QNX and embedded systems.

In his job experience he learned Java to develop user interfaces and graphical editors, and re-discovered the Eclipse IDE that he had used in its early versions with the QNX SDK. He also deepened his knowledge of Linux and embedded systems, microcontrollers firmware and embedded voice recognition, while also practicing electronics design.

He graduated in Computer Engineering (Ingegneria informatica) at the University of Pisa, Italy, in December 2003. Currently working for an electronics and robotics company (www.robotechsrl.com).

He lives in Pisa and in Follonica (GR), Italy.

Comments and Discussions

 
GeneralDialog did not respond when the animation activities Pin
golocy12-Jun-09 18:42
golocy12-Jun-09 18:42 
QuestionHow to show % completion Pin
Anonymous21-Sep-04 7:53
Anonymous21-Sep-04 7:53 
AnswerRe: How to show % completion Pin
Paolo Messina25-Sep-04 7:58
professionalPaolo Messina25-Sep-04 7:58 
Generalexcellent idea Pin
Jeremy Falcon7-May-03 12:01
professionalJeremy Falcon7-May-03 12:01 
Questionprogressbar ?? Pin
27-Sep-01 22:41
suss27-Sep-01 22:41 
AnswerRe: progressbar ?? Pin
Paolo Messina27-Sep-01 23:10
professionalPaolo Messina27-Sep-01 23:10 
GeneralWindows CE Pin
24-Apr-01 21:48
suss24-Apr-01 21:48 
GeneralRe: Windows CE Pin
Paolo Messina24-Apr-01 23:12
professionalPaolo Messina24-Apr-01 23:12 
GeneralRe: Windows CE Pin
27-Apr-01 7:17
suss27-Apr-01 7:17 
I've ported many controls to CE using Microsort's Embedded C++. The easiest way to port it is to include it in a CE project and compile. The compiler will cough on anything CE doesn't like. Usually its easy to find an alternative to offending code.
GeneralRe: Windows CE Pin
30-Apr-01 9:41
suss30-Apr-01 9:41 
GeneralRe: Windows CE Pin
8-Jun-02 23:25
suss8-Jun-02 23:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.