How to Implement the animated background flag

Source: Internet
Author: User

 

 

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.