#include "stdafx.h" #include "LayPosDlg.h" IMPLEMENT_DYNAMIC(CLayPosDlg, CDialog) CLayPosDlg::CLayPosDlg(CWnd* pParent /*=NULL*/) : CDialog(CLayPosDlg::IDD, pParent) , m_nLayPos(1) , m_nLays(0) { } CLayPosDlg::~CLayPosDlg() { } void CLayPosDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT1, m_nLayPos); DDX_Text(pDX, IDC_EDIT2, m_nLays); } BEGIN_MESSAGE_MAP(CLayPosDlg, CDialog) ON_BN_CLICKED(IDOK, &CLayPosDlg::OnBnClickedOk) END_MESSAGE_MAP() BOOL CLayPosDlg::OnInitDialog() { CDialog::OnInitDialog(); UpdateData(FALSE); return TRUE; } void CLayPosDlg::OnBnClickedOk() { UpdateData(); if (m_nLayPos <= 0 || m_nLayPos > m_nLays) { AfxMessageBox(_T("请输入正确的层位置序号!")); return; } OnOK(); }