The following code uses the CmdiMainClient class to display the animation background flag. The principle is very simple. We only need a series of continuous bitmaps to display them continuously. In this example, you can right-click the animation to start/stop the animation. If you click the left button, a subwindow is displayed to keep the animation going. For your convenience, you can copy the Code directly from the browser and insert it into your code. The following code is used:
# Include "stdafx. h"
# Include "banner. h"
# Include "mainfrm. h"
# Include "resource. h"
# Ifdef _ DEBUG
# Undef THIS_FILE
Static char BASED_CODE THIS_FILE [] = _ FILE __;
# Endif
//////////////////////////////////////// /////////////////////////////////////
// CMdiMainClient
CMdiMainClient: CMdiMainClient ()
:M_sizeClient (0, 0)
{
VERIFY (m_bmp background.loadbitmap (IDB_BCKGRD ));
ASSERT (m_bmp background.getsafehandle ());
VERIFY (m_bmp background2.loadbitmap (IDB_BITMAP0 ));
ASSERT (m_bmp background2.getsafehandle ());
BMP loaded = 1;
StopRotation = FALSE;
}
CMdiMainClient ::~ CMdiMainClient ()
{
If (m_bmp background.getsafehandle ())
M_bmp background.deleteobject ();
If (m_bmp background2.getsafehandle ())
M_bmp background2.deleteobject ();
}
BEGIN_MESSAGE_MAP (CMdiMainClient, CWnd)
// {AFX_MSG_MAP (CMdiMainClient)
// NOTE-the ClassWizard will add and remove mapping macros here.
ON_WM_TIMER ()
ON_WM_ERASEBKGND ()
ON_WM_RBUTTONDOWN ()
ON_WM_LBUTTONDOWN ()
ON_WM_SIZE ()
//} AFX_MSG_MAP
END_MESSAGE_MAP ()
//////////////////////////////////////// /////////////////////////////////////
// CMdiMainClient message handlers
BOOL CMdiMainClient: OnEraseBkgnd (CDC * pDC)
{
// Erase only the area needed
CRect rect;
GetClientRect (& rect );
SetTimer (0,300, NULL );
// Place the bitmap
BITMAP bm;
CDC dcMem;
& Nb