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

📄 dlgsum.cpp

📁 一个完整的彩票软件的源代码
💻 CPP
字号:
// DlgSum.cpp : implementation file
//

#include "stdafx.h"
#include "lottery.h"
#include "DlgSum.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgSum dialog


CDlgSum::CDlgSum(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSum::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgSum)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_isFilled=FALSE;
	m_pBuf=NULL;
	m_dMax=m_dAve=m_dStd=0;
	m_dMin=INT_MAX;
}


void CDlgSum::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSum)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSum, CDialog)
	//{{AFX_MSG_MAP(CDlgSum)
	ON_WM_PAINT()
	ON_WM_SIZE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSum message handlers

BOOL CDlgSum::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgSum::OnPaint() 
{
	int nBase=50;
	CPaintDC dc(this); // device context for painting
	CBrush bkBrush(RGB(64,64,64));
	dc.FillRect(CRect(0,0,m_nWidth,m_nHeight),&bkBrush);
	bkBrush.DeleteObject();
	CPen penCord(PS_SOLID,1,RGB(255,255,0)),penLine(PS_SOLID,1,RGB(0,255,0)),*pOldPen;
	pOldPen=dc.SelectObject(&penCord);
	dc.MoveTo(1,m_nHeight-nBase);
	dc.LineTo(m_nWidth,m_nHeight-nBase);
	
	CString strText;
	dc.SetTextColor(RGB(255,255,255));
	dc.SetBkColor(RGB(64,64,64));
	for (int i=20; i<220; i+=20)
	{
		strText.Format("%d",i);
		dc.TextOut(i*3-10,m_nHeight-nBase+7,strText);
		dc.MoveTo(i*3,m_nHeight-nBase);
		dc.LineTo(i*3,m_nHeight-nBase+9);
		dc.MoveTo(i*3-30,m_nHeight-nBase);
		dc.LineTo(i*3-30,m_nHeight-nBase+6);
		dc.MoveTo(i*3-45,m_nHeight-nBase);
		dc.LineTo(i*3-45,m_nHeight-nBase+3);
		dc.MoveTo(i*3-15,m_nHeight-nBase);
		dc.LineTo(i*3-15,m_nHeight-nBase+3);
	}
	if (m_dMin==INT_MAX)
	{
		double dSum=0;
		for (int i=0; i<m_nSize; i++)
		{
			dSum+=m_pBuf[i];
			if (m_pBuf[i] > m_dMax) m_dMax=m_pBuf[i];
			if (m_pBuf[i] < m_dMin) m_dMin=m_pBuf[i];
		}
		m_dAve=dSum/m_nSize;
		double dStd=0;
		for (i=0; i<m_nSize; i++)
		{
			dStd+=(m_pBuf[i] - m_dAve)*(m_pBuf[i] - m_dAve);
		}
		m_dStd=sqrt(dStd);
	}
	CRect rect3(m_nWidth-80,10,m_nWidth-10,80);
	CString str;
	str.Format("Max=%3d\r\nMin=%3d\r\nAve=%3d\r\nStd=%3d",(int)m_dMax,(int)m_dMin,(int)m_dAve,(int)m_dStd);
	dc.DrawText(str,&rect3,DT_RIGHT|DT_NOCLIP);
	dc.SelectObject(&penLine);
	for (i=0; i<m_nSize; i++)
	{
		UINT temp=m_pBuf[i];
		int nOrder=1;
		for (int j=i+1; j<m_nSize; j++)
		{
			if (temp != m_pBuf[j]) break;
			nOrder++;
		}
		dc.MoveTo(m_pBuf[i]*3,m_nHeight-nBase-1);
		dc.LineTo(m_pBuf[i]*3,m_nHeight-nBase-20*nOrder-1);
		i+=nOrder-1;
	}
	dc.SelectObject(pOldPen);
	penCord.DeleteObject();
	penLine.DeleteObject();
}

void CDlgSum::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	m_nWidth=cx;
	m_nHeight=cy;
	Invalidate();
}

void CDlgSum::OnDestroy() 
{
	CDialog::OnDestroy();
	
	if (m_pBuf)
	{
		delete [] m_pBuf;
	}
}

⌨️ 快捷键说明

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