65.9K
CodeProject is changing. Read more.
Home

CCloudsCtrl - Simulating clouds using MFC

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.91/5 (40 votes)

Dec 15, 2003

viewsIcon

133778

downloadIcon

3051

This control simulates clouds with scrolling text and can be used as an aboutbox.

Sample Image - CCloudsCtrl.jpg

Introduction

This class simulates clouds by using plasmas and a few 'simple' pixel operations.

3 layers of plasmas are blended together to build an image that looks like pretty realistic clouds (on a not so cloudy day...). There's also an option to enhance the clouds with an exponential function, to create an even more realistic looking sky. You can learn the complete theory by reading the excellent tutorial here. Unfortunately, this great article only gives us pseudo code, so we have to do the rest ourselves... The plasma implementation is partially based on code by Andrea Griffini (found on the Internet).

Usage

To use the class in your application, you need to do the following:

  1. Insert the .h and .cpp files into your project.
  2. Add a static control into your dialog resource.
  3. Add a member variable for that static control.
  4. Modify the variable declaration.

Change this:

CStatic m_CloudsCtrl;

To this:

CCloudsCtrl m_CloudsCtrl;

In your dialog's constructor, set text for the credits:

CString strCredits = "\tCCloudsCtrl Example\n\n"
      "\rProgrammed by:\n"
      "Pablo van der Meer\n\n\n"
      "\rSpecial thanks to:\nhttp://www.codeproject.com/\n\n\n"
      "Copyright © 2003 Pablo Software Solutions\n"
      "All right reserved.\n\n\n"
      "\rhttp:\\www.pablovandermeer.nl\n\n";

m_CloudsCtrl.SetCredits(strCredits);

Contacting the Author

Please send any comments or bug reports to me via email. For updates to this article (and many other articles), check my site.