cloudpanel.cpp

来自「这是一个很好的学习VC数据库的原马 大家可以参考以下 会收益非前的」· C++ 代码 · 共 83 行

CPP
83
字号
// CloudPanel.cpp : implementation file
//

#include "stdafx.h"
#include "DynamicCloud.h"
#include "CloudPanel.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCloudPanel

CCloudPanel::CCloudPanel()
{
	this->m_dDrops = NULL ;
	this->m_iDropSize = 0 ;
}

CCloudPanel::~CCloudPanel()
{
	if(this->m_dDrops != NULL)
		delete[] m_dDrops ;
}


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

/////////////////////////////////////////////////////////////////////////////
// CCloudPanel message handlers
double CCloudPanel::GetProperEX()
{
	RECT rect ;
    GetWindowRect(&rect) ;
	int temp = rect.right - rect.left ;
	return temp/2. ;

}

void CCloudPanel::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
    CBrush brush(RGB(255,255,255));

	RECT rect;
	GetWindowRect(&rect) ;
	double h = rect.bottom-rect.top ;
	double w = rect.right - rect.left  ;


	
	dc.FillRect(CRect(0,0,(int)w,(int)h),&brush);

	CPen pen(PS_SOLID,2,RGB(255,0,0));
	CPen *pOldPen=dc.SelectObject(&pen);
	
	if(m_dDrops != NULL) {
      
		for(int i = 0 ; i < m_iDropSize ; i ++) {

	      int x = (int)this->m_dDrops [i][0] ;
		  double ytemp = ( 1 - this->m_dDrops [i][1]) * (h-2) ;
		  int y = (int) ytemp ;

		  if( x >5 && x < w-5 && y >0) {

		  dc.MoveTo(x,y) ;
		  dc.LineTo(x,y) ;
		  }
		}
	
	}
	dc.SelectObject(pOldPen);	
	// Do not call CStatic::OnPaint() for painting messages
}

⌨️ 快捷键说明

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