📄 inputdialog.cpp
字号:
// InputDialog.cpp : implementation file
//
#include "stdafx.h"
#include "LuckyLottery.h"
#include "InputDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// InputDialog dialog
InputDialog::InputDialog(CWnd* pParent /*=NULL*/)
: CDialog(InputDialog::IDD, pParent)
{
char buffer[(9 * 15)];
//{{AFX_DATA_INIT(InputDialog)
m_input_lottery = _T("");
m_display_lottery = _T("");
//}}AFX_DATA_INIT
pFileName = _T("E:\\vc_work\\LOTTERY\\LotteryFile.txt");
MyFile.Open(pFileName, CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite);
if (MyFile.GetLength() < (9 * 15))
MyFile.SeekToBegin();
else
MyFile.Seek(-(9 * 15), CFile::end);
memset(buffer, 0, (9 * 15));
MyFile.Read(buffer, (9 * 15));
m_display_lottery += buffer;
}
void InputDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(InputDialog)
DDX_Text(pDX, IDC_INPUT_LOTTERY, m_input_lottery);
DDV_MaxChars(pDX, m_input_lottery, 7);
DDX_Text(pDX, IDC_DISPLAY_LOTTERY, m_display_lottery);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(InputDialog, CDialog)
//{{AFX_MSG_MAP(InputDialog)
ON_BN_CLICKED(IDC_NEXT_LOTTERY, OnNextLottery)
ON_BN_CLICKED(ID_FINISH_LOTTERY, OnFinishLottery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// InputDialog message handlers
void InputDialog::OnNextLottery()
{
// TODO: Add your control notification handler code here
char buffer[9 * (IN_NUM/OUT_NUM)];
UpdateData(TRUE);
m_input_lottery += '\n';
for(int i=0; i<7; i++)
if ((m_input_lottery[i] > '9') || (m_input_lottery[i] < '0'))
{
AfxMessageBox("输入错误,请重输!");
return;
}
MyFile.SeekToEnd();
MyFile.Write(m_input_lottery, 8);
if (MyFile.GetLength() < (9 * (IN_NUM / OUT_NUM)))
MyFile.SeekToBegin();
else
MyFile.Seek(-(9 * (IN_NUM / OUT_NUM)), CFile::end);
m_display_lottery = _T("");
memset(buffer, 0, (9 * (IN_NUM / OUT_NUM)));
MyFile.Read(buffer, (9 * (IN_NUM / OUT_NUM)));
m_display_lottery += buffer;
m_input_lottery = _T("");
UpdateData(FALSE);
}
void InputDialog::OnFinishLottery()
{
// TODO: Add your control notification handler code here
MyFile.Close();
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -