📄 outputdialog.cpp
字号:
// OutputDialog.cpp : implementation file
//
#include "stdafx.h"
#include "LuckyLottery.h"
#include "OutputDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// OutputDialog dialog
OutputDialog::OutputDialog(CWnd* pParent /*=NULL*/)
: CDialog(OutputDialog::IDD, pParent)
{
pFileName = _T("E:\\vc_work\\LOTTERY\\LotteryFile.txt");
MyFile.Open(pFileName, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeRead);
//{{AFX_DATA_INIT(OutputDialog)
m_out_pos = IN_NUM/7;
m_real_output = _T("");
m_teach_output = _T("");
m_five_input = _T("");
m_five_input2 = _T("");
m_five_input3 = _T("");
m_five_input4 = _T("");
//}}AFX_DATA_INIT
}
void OutputDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(OutputDialog)
DDX_Text(pDX, IDC_OUT_LOTTERY_POS, m_out_pos);
DDX_Text(pDX, IDC_REAL_OUTPUT, m_real_output);
DDX_Text(pDX, IDC_TEACH_OUTPUT, m_teach_output);
DDX_Text(pDX, IDC_DISPALY_FIVE_LOTTERY, m_five_input);
DDX_Text(pDX, IDC_DISPALY_FIVE_LOTTERY2, m_five_input2);
DDX_Text(pDX, IDC_DISPALY_FIVE_LOTTERY3, m_five_input3);
DDX_Text(pDX, IDC_DISPALY_FIVE_LOTTERY4, m_five_input4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(OutputDialog, CDialog)
//{{AFX_MSG_MAP(OutputDialog)
ON_BN_CLICKED(IDC_FINISH_OUTPUT, OnFinishOutput)
ON_BN_CLICKED(IDC_READ_LOTTERY, OnReadLottery)
ON_BN_CLICKED(IDC_OUTPUT_LOTTERY, OnOutputLottery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// OutputDialog message handlers
void OutputDialog::OnFinishOutput()
{
// TODO: Add your control notification handler code here
MyFile.Close();
OnOK();
}
void OutputDialog::OnReadLottery()
{
// TODO: Add your control notification handler code here
char buffer[9 * (IN_NUM/7) + 9];
UpdateData(TRUE);
if ((m_out_pos < (IN_NUM/7))||(m_out_pos > 1000))
{
AfxMessageBox("请输入一个介于(IN_NUM / 7)和1000之间的整数!");
return;
}
m_teach_output = _T("");
m_input = _T("");
m_five_input = _T("");
m_five_input2 = _T("");
m_five_input3 = _T("");
m_five_input4 = _T("");
MyFile.Seek(-(m_out_pos * 9), CFile::end);
memset(buffer, 0, (9 * (IN_NUM/7) + 9));
// if (m_out_pos > (IN_NUM/7))
{
MyFile.Read(buffer, ((IN_NUM/7) * 8 + 8));
m_teach_output = buffer + ((IN_NUM/7) * 8);
}
// else
// {
// MyFile.Read(buffer, (IN_NUM/7)*8 + 8);
// m_teach_output = buffer + ((IN_NUM/7) * 8);
// }
m_input += buffer;
buffer[(IN_NUM / 7) * 8 - 1] = 0;
buffer[(IN_NUM / 7) * 6 - 1] = 0;
buffer[(IN_NUM / 7) * 4 - 1] = 0;
buffer[(IN_NUM / 7) * 2 - 1] = 0;
m_five_input = buffer;
m_five_input2 = buffer + (IN_NUM / 7) * 2 ;
m_five_input3 = buffer + (IN_NUM / 7) * 4 ;
m_five_input4 = buffer + (IN_NUM / 7) * 6 ;
UpdateData(FALSE);
}
void OutputDialog::OnOutputLottery()
{
// TODO: Add your control notification handler code here
m_real_output = ((CLuckyLotteryApp *)AfxGetApp())->ForecastLottery(m_input);
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -