📄 dialognew.cpp
字号:
// DialogNew.cpp : implementation file
//
#include "stdafx.h"
#include "map.h"
#include "DialogNew.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogNew dialog
CDialogNew::CDialogNew(CWnd* pParent /*=NULL*/)
: CDialog(CDialogNew::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogNew)
m_name_new = _T("");
//}}AFX_DATA_INIT
}
void CDialogNew::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogNew)
DDX_Text(pDX, IDC_CITYNAME_NEW_EDIT, m_name_new);
DDV_MaxChars(pDX, m_name_new, 15);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogNew, CDialog)
//{{AFX_MSG_MAP(CDialogNew)
ON_BN_CLICKED(IDC_INPUT, OnInput)
ON_BN_CLICKED(IDC_OVER_BUTTON, OnOverButton)
//ON_COMMAND(IDC_CITYNAME_NEW_EDIT,OnNameNew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogNew message handlers
CList<CString,CString &> & CDialogNew::GetCityNameList()
{
return m_citynamelist;
}
int CDialogNew::DoModal()
{
m_citynamelist.RemoveAll();
return CDialog::DoModal();
}
void CDialogNew::OnInput()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_name_new.IsEmpty()) {AfxMessageBox("你没有输入城市名,请重输!");return;}
int tp=-1;//检验字符串是否为无效!
POSITION pos(NULL);
tp=m_name_new.Find(" ");
if(tp!=-1) {AfxMessageBox("请不要输入空格!");PrevDlgCtrl( );return;}
pos=m_citynamelist.Find(m_name_new);
if(pos!=NULL) {AfxMessageBox("你输入的城市已经存在!请重输!");PrevDlgCtrl( );return;}
m_citynamelist.AddTail(m_name_new);
m_name_new=_T("");
UpdateData(false);
PrevDlgCtrl( );
}
//DEL void CDialogNew::OnCancel()
//DEL {
//DEL // TODO: Add extra cleanup here
//DEL EndDialog(11);
//DEL }
void CDialogNew::OnOverButton()
{
// TODO: Add your control notification handler code here
EndDialog(11);
}
//void CDialogNew::OnNameNew()
//{
// OnInput();
//}
//DEL void CDialogNew::OnKillfocusCitynameNewEdit()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL m_input.GetDiaItem(IDC_INPUT)
//DEL
//DEL }
void CDialogNew::OnOK()
{
OnInput();
PrevDlgCtrl( );
PrevDlgCtrl( );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -