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

Animated Dialog Windows

Rate me:
Please Sign up or sign in to vote.
4.93/5 (38 votes)
17 Apr 2000 234.7K   7.3K   128  
A class that provides some simple, yet spectacular window animation effects. Try the demo!
// Written by SiGMan / iO UpG  13-04-2000
// 
//
// AnimEffect.h: interface for the AnimEffect class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_ANIMEFFECT_H__9AED4B93_0A83_4B4E_B6ED_1B3A133E2600__INCLUDED_)
#define AFX_ANIMEFFECT_H__9AED4B93_0A83_4B4E_B6ED_1B3A133E2600__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

enum AnimType {
	AnimInit, AnimDraw, AnimErase, AnimTerm
};

struct AnimData
{
	BOOL	bOpen;
	RECT	rcScreen;
	RECT	rcWnd;
	int		iParameter;
	int		iAfterimages;
	int		iTotalSteps;
	int		iStep;
	POINT	ptRelRightTop;
	POINT	ptCenter;
	HWND	hWnd;
	HDC		hDC;
	enum	AnimType animType;
	BYTE	bBuffer[4000];
};


class AnimEffect  
{
public:
	enum EffectType {
		Random=-1,
		Spin=0,
		Vortex,
		ScatterGather,
		Spike,
		Fireworks
	};

	typedef BOOL (*EFFUNC)( AnimData * );

	AnimEffect();
	virtual ~AnimEffect();

	void Setup( int iSteps, int iAfterimages, int iDelay = 10);
	void Effect( EffectType effect );
	void Open( const CRect &rcWnd );
	void Close( const CRect &rcWnd );

private:
	void Defaults();
	void ChooseFunc();
	void Animate( AnimData &animData );

private:
	RECT	m_rcScreen;
	int		m_iParameter;
	int		m_iAfterimages;
	int		m_iTotalSteps;
	int		m_iDelay;
	EffectType	m_Effect;
	EFFUNC	m_Func;

	RECT	m_rcWnd;
	POINT	m_ptRelRightTop;
	POINT	m_ptCenter;

	HWND	m_hWnd;
	HDC		m_hDC;
	HPEN	m_hPen;
};

#endif // !defined(AFX_ANIMEFFECT_H__9AED4B93_0A83_4B4E_B6ED_1B3A133E2600__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions