📄 textdlg.cpp
字号:
// TextDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resourceeditor.h"
#include "TextDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextDlg dialog
CTextDlg::CTextDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTextDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTextDlg)
m_strEnglish = _T("");
m_strID = _T("");
m_strSimpleChinese = _T("");
m_strTraditionalChinese = _T("");
//}}AFX_DATA_INIT
m_bCanModifyID = TRUE;
}
void CTextDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTextDlg)
DDX_Text(pDX, IDC_EDT_ENGLISH, m_strEnglish);
DDX_Text(pDX, IDC_EDT_ID, m_strID);
DDX_Text(pDX, IDC_EDT_SIMPL_CHINESE, m_strSimpleChinese);
DDX_Text(pDX, IDC_EDT_TRADI_CHINESE, m_strTraditionalChinese);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTextDlg, CDialog)
//{{AFX_MSG_MAP(CTextDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTextDlg message handlers
void CTextDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if( m_bCanModifyID )
{
if( m_strID.IsEmpty() )
{
AfxMessageBox(_T("The ID isn't empty!"));
return;
}
if( m_strID[0] >= _T('0') && m_strID[0] <= _T('9') )
{
AfxMessageBox(_T("The ID's first character can't be a number!"));
return;
}
if( g_theApp.m_MMIRes.TextIDIsExist(m_strID) )
{
AfxMessageBox(_T("The ID already exist, please reinput!"));
return;
}
m_strID.MakeUpper();
}
CDialog::OnOK();
}
BOOL CTextDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CWnd * pWnd = GetDlgItem(IDC_EDT_ID);
_ASSERTE( pWnd != NULL );
CWnd * pFocus = GetFocus();
if( pMsg->message == WM_CHAR && pFocus != NULL && pFocus->m_hWnd == pWnd->m_hWnd )
{
_TCHAR cInput = pMsg->wParam;
if( cInput < _T('0') || cInput > _T('9') )
{
if( cInput < _T('a') || cInput > _T('z') )
{
if( cInput != _T('_') && (cInput < _T('A') || cInput > _T('Z')) )
{
if( !(GetKeyState(VK_LCONTROL) & 0x0100) )
return TRUE;
}
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CTextDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if( !m_bCanModifyID )
{
CWnd * pWnd = GetDlgItem(IDC_EDT_ID);
_ASSERTE( pWnd != NULL );
pWnd->EnableWindow(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -