// DlgInput.cpp : implementation file // #include "stdafx.h" #include "hgjson.h" #include "DlgInput.h" #include "afxdialogex.h" // CDlgInput dialog IMPLEMENT_DYNAMIC(CDlgInput, CDialogEx) CDlgInput::CDlgInput(CWnd* pParent /*=NULL*/) : CDialogEx(CDlgInput::IDD, pParent) , value_(_T("")), type_(INPUT_FOR_NAME) { } CDlgInput::~CDlgInput() { } void CDlgInput::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Text(pDX, IDC_EDIT1, value_); } BOOL CDlgInput::OnInitDialog() { CDialogEx::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog return TRUE; // return TRUE unless you set the focus to a control } BEGIN_MESSAGE_MAP(CDlgInput, CDialogEx) ON_BN_CLICKED(IDOK, &CDlgInput::OnBnClickedOk) END_MESSAGE_MAP() // CDlgInput message handlers void CDlgInput::OnBnClickedOk() { // TODO: Add your control notification handler code here UpdateData(); if (value_.IsEmpty()) { ::MessageBoxW(m_hWnd, L"ÇëÊäÈëÄÚÈÝ", L"Error", MB_OK | MB_ICONSTOP); GotoDlgCtrl(GetDlgItem(IDC_EDIT1)); return; } if (type_ == INPUT_FOR_NAME) { wchar_t text[128] = { 0 }; ::GetDlgItemTextW(m_hWnd, IDC_EDIT1, text, _countof(text) - 1); for (size_t i = 0; i < used_names_.size(); ++i) { if (used_names_[i] == text) { std::wstring t(used_names_[i] + L" is already used, choose another name, plz."); ::MessageBoxW(m_hWnd, t.c_str(), L"Sorry", MB_OK); return; } } } CDialogEx::OnOK(); }