📄 createdlg.cpp
字号:
// CreateDlg.cpp : implementation file
//
#include "stdafx.h"
#include "WeiQiClient.h"
#include "CreateDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreateDlg dialog
CCreateDlg::CCreateDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCreateDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCreateDlg)
m_GameNameEdit = _T("");
//}}AFX_DATA_INIT
}
void CCreateDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCreateDlg)
DDX_Text(pDX, IDC_EDIT_GAMENAME, m_GameNameEdit);
DDV_MaxChars(pDX, m_GameNameEdit, 30);
DDX_Control(pDX,IDC_BUTTON_YES,m_CreateButton);
DDX_Control(pDX,IDC_BUTTON_NO,m_CancelButton);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCreateDlg, CDialog)
//{{AFX_MSG_MAP(CCreateDlg)
ON_BN_CLICKED(IDC_BUTTON_YES, OnButtonYes)
ON_BN_CLICKED(IDC_BUTTON_NO, OnButtonNo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreateDlg message handlers
BOOL CCreateDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_CreateButton.LoadButtonBmp(IDB_BITMAPCREATE1,IDB_BITMAPCREATE2,IDB_BITMAPCREATE3,IDB_BITMAPCONNECTBK);
m_CancelButton.LoadButtonBmp(IDB_BITMAPEXIT1,IDB_BITMAPEXIT2,IDB_BITMAPEXIT3,IDB_BITMAPCONNECTBK);
m_Tip.Create(this);
m_Tip.AddTool(&m_CreateButton,_T("确定"));
m_Tip.AddTool(&m_CancelButton,_T("取消"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCreateDlg::OnButtonYes()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_GameNameEdit.IsEmpty())
{
MessageBox(_T("游戏名不能为空"));
return;
}
if(m_GameNameEdit.GetLength()>30)
{
MessageBox(_T("游戏名太长"));
return;
}
if(m_GameNameEdit.Find(_T(' '))!=-1)
{
MessageBox(_T("游戏名中不许出现空格"));
return;
}
OnOK();
}
void CCreateDlg::OnButtonNo()
{
// TODO: Add your control notification handler code here
OnCancel();
}
BOOL CCreateDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
m_Tip.RelayEvent(pMsg);
if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==13)
{
OnButtonYes();
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -