📄 sdgdbhdlg1.cpp
字号:
// sdgdbhdlg1.cpp : implementation file
//
#include "stdafx.h"
#include "xxgl.h"
#include "sdgdbhdlg1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Csdgdbhdlg1 dialog
static cur_focus;
switch_to_english_mode(CWnd *wnd);
switch_to_chinese_mode(CWnd *wnd);
Set_to_item_end(CWnd *wd,int id);
Csdgdbhdlg1::Csdgdbhdlg1(CWnd* pParent /*=NULL*/)
: CDialog(Csdgdbhdlg1::IDD, pParent)
{
//{{AFX_DATA_INIT(Csdgdbhdlg1)
m_jsgdbh = _T("");
m_qsgdbh = _T("");
//}}AFX_DATA_INIT
cur_focus = 0;
}
void Csdgdbhdlg1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Csdgdbhdlg1)
DDX_Text(pDX, IDC_jsgdbh, m_jsgdbh);
DDX_Text(pDX, IDC_qsgdbh, m_qsgdbh);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Csdgdbhdlg1, CDialog)
//{{AFX_MSG_MAP(Csdgdbhdlg1)
ON_EN_CHANGE(IDC_qsgdbh, OnChangeqsgdbh)
ON_EN_CHANGE(IDC_jsgdbh, OnChangejsgdbh)
ON_EN_SETFOCUS(IDC_jsgdbh, OnSetfocusjsgdbh)
ON_EN_SETFOCUS(IDC_qsgdbh, OnSetfocusqsgdbh)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Csdgdbhdlg1 message handlers
void Csdgdbhdlg1::OnChangeqsgdbh()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
char buf[20];
GetDlgItemText(IDC_qsgdbh,buf,20);
int l,i;
l = strlen(buf);
if (l > 6){
buf[6] = 0;
SetDlgItemText(IDC_qsgdbh,buf);
Set_to_item_end(this,IDC_qsgdbh);
}
if (l > 0){
for (i=0;i<l;i++){
if ((buf[i] < '0')||(buf[i] > '9')){
buf[i] = 0;
SetDlgItemText(IDC_qsgdbh,buf);
Set_to_item_end(this,IDC_qsgdbh);
}
}
}
}
void Csdgdbhdlg1::OnChangejsgdbh()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
char buf[20];
GetDlgItemText(IDC_jsgdbh,buf,20);
int l,i;
l = strlen(buf);
if (l > 6){
buf[6] = 0;
SetDlgItemText(IDC_jsgdbh,buf);
Set_to_item_end(this,IDC_jsgdbh);
}
if (l > 0){
for (i=0;i<l;i++){
if ((buf[i] < '0')||(buf[i] > '9')){
buf[i] = 0;
SetDlgItemText(IDC_jsgdbh,buf);
Set_to_item_end(this,IDC_jsgdbh);
}
}
}
}
void Csdgdbhdlg1::OnOK()
{
// TODO: Add extra validation here
char buf[20];
CWnd *wn_qsgdbh;
CWnd *wn_jsgdbh;
long bl,el;
CWnd *wn_cur;
CWnd *wn_ok;
wn_qsgdbh = GetDlgItem(IDC_qsgdbh);
wn_jsgdbh = GetDlgItem(IDC_jsgdbh);
wn_ok = GetDlgItem(IDOK);
wn_cur = GetFocus();
if (wn_cur->m_hWnd != wn_ok->m_hWnd){
if (cur_focus == 1){
wn_jsgdbh->SetFocus();
return ;
}
}
GetDlgItemText(IDC_qsgdbh,buf,20);
if ((strlen(buf) != 6)&&(buf[0] != 0)){
MessageBox("起始固定编号错误.",MB_OK);
wn_qsgdbh->SetFocus();
return;
}
GetDlgItemText(IDC_jsgdbh,buf,20);
if ((strlen(buf) != 6)&&(buf[0] != 0)){
MessageBox("结束固定编号错误.",MB_OK);
wn_jsgdbh->SetFocus();
return;
}
GetDlgItemText(IDC_qsgdbh,buf,20);
bl = atol(buf);
GetDlgItemText(IDC_jsgdbh,buf,20);
el = atol(buf);
if ((bl > el)&&(bl != 0)&&(el != 0)){
MessageBox("输入的起始编号大于结束编号,请重新输入.","",MB_OK);
wn_qsgdbh->SetFocus();
return;
}
CDialog::OnOK();
}
void Csdgdbhdlg1::OnSetfocusjsgdbh()
{
// TODO: Add your control notification handler code here
CWnd *wnd;
wnd = GetDlgItem(IDC_jsgdbh);
switch_to_english_mode(wnd);
cur_focus = 2;
}
void Csdgdbhdlg1::OnSetfocusqsgdbh()
{
// TODO: Add your control notification handler code here
CWnd *wnd;
wnd = GetDlgItem(IDC_qsgdbh);
switch_to_english_mode(wnd);
cur_focus = 1;
}
void Csdgdbhdlg1::OnTab()
{
// TODO: Add your control notification handler code here
CWnd *wn_jsgdbh;
wn_jsgdbh = GetDlgItem(IDC_jsgdbh);
if (cur_focus == 1){
wn_jsgdbh->SetFocus();
return ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -