⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chuansong.cpp

📁 操作系统为winCE
💻 CPP
字号:
// chuansong.cpp : implementation file
//

#include "stdafx.h"
#include "test_chuansong.h"
#include "chuansong.h"
#include "MemDC.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Cchuansong

Cchuansong::Cchuansong()
{
	m_shan=0;
	m_shan_bool=FALSE;
}

Cchuansong::~Cchuansong()
{
}


BEGIN_MESSAGE_MAP(Cchuansong, CStatic)
	//{{AFX_MSG_MAP(Cchuansong)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cchuansong message handlers

void Cchuansong::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	GetClientRect (&m_rect);
 
	CMemDC memDC(&dc, &m_rect);

	if(m_dcBack.GetSafeHdc()== NULL|| (m_bitmap.m_hObject == NULL) )  //如果m_dcBack与m_bitmap都没有被使用,则
	{                                                                 //可用
        m_dcBack.CreateCompatibleDC(&dc);
		m_bitmap.CreateCompatibleBitmap(&dc, m_rect.Width(), m_rect.Height());
        m_pBitmapOld = m_dcBack.SelectObject(&m_bitmap) ;
        draw_chuan(&m_dcBack, m_rect);
//	    MessageBox(_T("ha_paint")); 
	}  
		memDC.BitBlt(0, 0, m_rect.Width(), m_rect.Height(), 
			           &m_dcBack, 0, 0, SRCCOPY) ;

	// Do not call CStatic::OnPaint() for painting messages
}

void Cchuansong::draw_chuan(CDC *pDC, CRect &rect)
{
   	CBrush brushFill,*pBrushOld;

    brushFill.DeleteObject();
	brushFill.CreateSolidBrush(RGB(128,128,128));
	pBrushOld = pDC->SelectObject(&brushFill);

 	pDC->Rectangle(rect);
	pDC->SelectObject(pBrushOld); 
    brushFill.DeleteObject();
	pBrushOld->DeleteObject();
//---------------闪动部分-----------------------//
	brushFill.CreateSolidBrush(RGB(0,255,0));
	pBrushOld = pDC->SelectObject(&brushFill);

	if(m_shan_bool==FALSE)
	{   
		pDC->Rectangle(rect.left,rect.bottom*(11-m_shan)/12,rect.right,rect.bottom*(12-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(14-m_shan)/12,rect.right,rect.bottom*(15-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(17-m_shan)/12,rect.right,rect.bottom*(18-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(20-m_shan)/12,rect.right,rect.bottom*(21-m_shan)/12);
	}
	if(m_shan_bool==TRUE)
	{
		pDC->Rectangle(rect.left,rect.bottom*(-1-m_shan)/12,rect.right,rect.bottom*(0-m_shan)/12);
		pDC->Rectangle(rect.left,rect.bottom*(2-m_shan)/12,rect.right,rect.bottom*(3-m_shan)/12);
		pDC->Rectangle(rect.left,rect.bottom*(5-m_shan)/12,rect.right,rect.bottom*(6-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(8-m_shan)/12,rect.right,rect.bottom*(9-m_shan)/12);

        pDC->Rectangle(rect.left,rect.bottom*(11-m_shan)/12,rect.right,rect.bottom*(12-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(14-m_shan)/12,rect.right,rect.bottom*(15-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(17-m_shan)/12,rect.right,rect.bottom*(18-m_shan)/12);
        pDC->Rectangle(rect.left,rect.bottom*(20-m_shan)/12,rect.right,rect.bottom*(21-m_shan)/12);
	}

	int temp1;
    temp1=11;
	pDC->SelectObject(pBrushOld); 
    brushFill.DeleteObject();
	pBrushOld->DeleteObject();



}

void Cchuansong::shan()
{
	if(m_shan<13)
		m_shan++;
	if(m_shan==13)
	{	m_shan_bool=TRUE;
		m_shan=0;
 	}

	if ((m_pBitmapOld) && (m_bitmap.GetSafeHandle()) && (m_dcBack.GetSafeHdc()))
	{
			m_dcBack.SelectObject(m_pBitmapOld);
			m_dcBack.DeleteDC();
			m_bitmap.DeleteObject();
	}        
    Invalidate();
	Cchuansong::OnPaint();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -