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

📄 lottery.cpp

📁 一个完整的彩票软件的源代码
💻 CPP
字号:
// Lottery.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Lottery.h"

#include "MainFrm.h"
#include "HyperLinkStatic.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLotteryApp

BEGIN_MESSAGE_MAP(CLotteryApp, CWinApp)
	//{{AFX_MSG_MAP(CLotteryApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLotteryApp construction

CLotteryApp::CLotteryApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CLotteryApp object

CLotteryApp theApp;
CListCtrl * g_pList;
/////////////////////////////////////////////////////////////////////////////
// CLotteryApp initialization

BOOL CLotteryApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));


	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.

	CMainFrame* pFrame = new CMainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);



	SetDialogBkColor(RGB(200,255,255));
	// The one and only window has been initialized, so show and update it.
	pFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pFrame->UpdateWindow();

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CLotteryApp message handlers





/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CHyperLinkStatic	m_mailto;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	afx_msg void OnStaticMailto();
	virtual BOOL OnInitDialog();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_STATIC_MAILTO, m_mailto);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_BN_CLICKED(IDC_STATIC_MAILTO, OnStaticMailto)
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CLotteryApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CLotteryApp message handlers

int LOTTERY::GetAC()
{
	int ac[30];
	ZeroMemory((void*)ac,30*sizeof(int));
	for (int i=1; i<8; i++)
		for (int j=i+1; j<8; j++)
		{
			ac[abs(this->i[i] - this->i[j])]=1;
		}
	int sum=0;
	for (i=0; i<30; i++)
	{
		sum+=ac[i];
	}
	return (sum-6);
}
//------------------获得两期彩票号码的差异--------------------//
void LOTTERY::GetDifference( LOTTERY *plot, int *num, UINT *buf)
{
	int nNum=0;
	for (int i=1; i<9; i++)
	{
		for (int j=1; j<9; j++)
		{
			if (this->i[i] == plot->i[j]) 
			{
				buf[nNum++]=this->i[i];
			}
		}
	}
	*num=nNum;
}
//------------------字符串转换为彩票号码--------------------//
BOOL LOTTERY::GetLotteryFromStr(CString &strBuf)
{
	CString strNum;
	UINT lty[7];
	int k=0;
	int len=strBuf.GetLength();
	int i=0;
	refill:
		while(i<len && (strBuf.GetAt(i) < 48 || strBuf.GetAt(i) > 57)) i++;

		int j=i;
		while(i<len && strBuf.GetAt(i) > 47 && strBuf.GetAt(i) < 58) i++;
		strNum=strBuf.Mid(j,i-j);
		lty[k]=atoi(strNum.GetBuffer(strNum.GetLength()));
		if (lty[k]>30) 
		{
			return false;
		}
		k++;
		if (k==7)
		{
			goto end;
		}
		if (i>=len)return FALSE;
		if (k<7) goto refill;
	end:
		for (i=0; i<7; i++)
		{
			this->i[i+1]=lty[i];
		}
		return TRUE;
}


UINT LOTTERY::GetSum()
{
	UINT sum=0;
	for (int i=1; i<8; i++)
	{
		sum+=this->i[i];
	}
	return sum;
}

int LOTTERY::GetEvenNumber(BOOL bSpecial)
{
	int even=0;
	int Num=8;
	if (bSpecial) Num++;
	for (int i=1; i<8; i++)
	{
		if ((this->i[i] % 2)==1)
			even++;
	}
	return even;
}

int LOTTERY::GetBonusGrade(LOTTERY *plot)
{
	int nSum=0;
	int nSpecial=0;
	for (int i=1; i<8; i++)
	{
		for (int j=1; j<8; j++)
		{
			if (this->i[i]==plot->i[j]) nSum++;
		}
		if  (this->i[i]==plot->i[8]) nSpecial=1;
	}
	if (nSum==7) return 1;
	if (nSum==6 && nSpecial) return 2;
	if (nSum==6) return 3;
	if (nSum==5 && nSpecial) return 4;
	if (nSum==5) return 5;
	if (nSum==4 && nSpecial) return 6;
	if (nSum==4) return 7;
	return 8;
}

void CAboutDlg::OnStaticMailto() 
{
	CString str;
	str="mailto:hugos@21cn.com";
	ShellExecute(m_hWnd,"open",str,NULL,NULL,SW_SHOWNORMAL);
}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	HCURSOR hcursor=AfxGetApp()->LoadCursor(IDC_CURSOR_HAND);

	m_mailto.SetCursor(hcursor);
	
	CString strComments;
	strComments="本软件属于共享软件,未经允许可以自由拷贝。\r\n\
由于使用本软件给您造成的任何精神及物质上的损失,本软件作者概不负责。\r\n\
本软件的注册费用为人民币2元整。\r\n\
注册过的软件将会有中奖号码的添加功能,并且注册人将完全免费享有本软件的升级功能。\r\n\
汇款请寄:\r\n\
XX省XX市 XXX 收\r\n\
邮政编码:XXXXXX \r\n\
电话:0xxx-xxxxxxx-xxxx\r\n\
当然您不注册也无所谓了。如果您注册了,将是对我工作的一点肯定吧。\r\n\
欢迎您把对本软件的建议和BUG通知我。得了大奖也要通知我喽。\r\n\
!!!!!!祝您好运!!!!!!";
	SetDlgItemText(IDC_EDIT_COMMENTS,strComments);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	m_mailto.Invalidate();	
	CDialog::OnMouseMove(nFlags, point);
}

BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message==WM_MOUSEMOVE)
	{
		if (pMsg->hwnd==m_mailto.m_hWnd)
		{
			SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_HAND));
		}
		else
		{
			SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
		}
	}
	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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