📄 dialogconffirststep.cpp
字号:
// DialogConfFirstStep.cpp : implementation file
//
#include "stdafx.h"
#include "WinLottory.h"
#include "DialogConfFirstStep.h"
#include "WinLottoryDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogConfFirstStep dialog
CDialogConfFirstStep::CDialogConfFirstStep(CWnd* pParent /*=NULL*/)
: CDialog(CDialogConfFirstStep::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogConfFirstStep)
m_num1 = 1;
m_num2 = 1;
m_num3 = 1;
m_static1 = _T("一等奖");
m_static2 = _T("二等奖");
m_static3 = _T("三等奖");
m_static_main = _T("第一步:\n设置每个奖项的中奖人数");
//}}AFX_DATA_INIT
}
void CDialogConfFirstStep::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogConfFirstStep)
DDX_Control(pDX, IDC_BUTTON3, m_cancel);
DDX_Control(pDX, IDC_BUTTON2, m_nextSetp);
DDX_Text(pDX, IDC_EDIT1, m_num1);
DDV_MinMaxInt(pDX, m_num1, 1, 100);
DDX_Text(pDX, IDC_EDIT2, m_num2);
DDV_MinMaxInt(pDX, m_num2, 1, 300);
DDX_Text(pDX, IDC_EDIT3, m_num3);
DDV_MinMaxInt(pDX, m_num3, 1, 500);
DDX_Text(pDX, IDC_STATIC_1, m_static1);
DDV_MaxChars(pDX, m_static1, 6);
DDX_Text(pDX, IDC_STATIC_2, m_static2);
DDV_MaxChars(pDX, m_static2, 6);
DDX_Text(pDX, IDC_STATIC_3, m_static3);
DDV_MaxChars(pDX, m_static3, 6);
DDX_Text(pDX, IDC_STATIC_MAIN, m_static_main);
DDV_MaxChars(pDX, m_static_main, 50);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogConfFirstStep, CDialog)
//{{AFX_MSG_MAP(CDialogConfFirstStep)
ON_WM_CANCELMODE()
ON_WM_DESTROY()
ON_WM_CAPTURECHANGED()
ON_BN_CLICKED(IDC_BUTTON2, OnButtonNextStep)
ON_BN_CLICKED(IDC_BUTTON3, OnButtonCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogConfFirstStep message handlers
BOOL CDialogConfFirstStep::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogConfFirstStep::OnCancelMode()
{
CDialog::OnCancelMode();
// TODO: Add your message handler code here
}
void CDialogConfFirstStep::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
void CDialogConfFirstStep::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
CDialog::OnCaptureChanged(pWnd);
}
void CDialogConfFirstStep::OnButtonNextStep()
{
UpdateData(true);
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
CWinLottoryDoc *pDoc = (CWinLottoryDoc *) pFrame->GetActiveDocument();
(pDoc->m_nLottory)[0]=m_num1;
(pDoc->m_nLottory)[1]=m_num2;
(pDoc->m_nLottory)[2]=m_num3;
CFileDialog pFileDlg(TRUE,".*",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"*(*.*)|*.*||");
if(pFileDlg.DoModal()==IDOK)
{
if (pDoc->m_nFlag==1)
{
pDoc->m_nIfSetTimer=0;
pDoc->m_nIfTimer=0;
pDoc->m_nFlag=0;
pDoc->m_nLottoryTimes=2;
}
if (&pDoc->m_sLottoryData)
{
pDoc->m_sLottoryData.RemoveAll();
}
if (&pDoc->m_sLottoryBingo)
{
pDoc->m_sLottoryBingo.RemoveAll();
}
// 获得抽奖数据的文件名
pDoc->m_sLottoryFileName=pFileDlg.GetPathName();
// 打开并读取文件,将数据放入str中
pDoc->m_sLottoryFile.Open(pDoc->m_sLottoryFileName,CFile::modeRead);
CString lineString;
// 解析每行数据,放入string数组中
while(pDoc->m_sLottoryFile.ReadString(lineString)!=FALSE)
{
pDoc->m_sLottoryData.Add(lineString);
}
// 关闭文件
pDoc->m_sLottoryFile.Close();
/* 调试信息
for (int i =0 ;i<pDoc->m_sLottoryData.GetSize();i++)
{
MessageBox(pDoc->m_sLottoryData.GetAt(i));
}*/
}
EndDialog(0);
}
void CDialogConfFirstStep::OnButtonCancel()
{
EndDialog(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -