Merge pull request '保存航线文件时增加高度输入校验' (#12) from dev/zpx into master

Reviewed-on: #12
pull/14/head
WuChengbo 2 years ago
commit 910a299595

@ -8,6 +8,7 @@
#include "string" #include "string"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <regex>
// CModifyLinePointDlg 对话框 // CModifyLinePointDlg 对话框

@ -1,16 +1,17 @@
// SetSaveLineID.cpp : implementation file // SetSaveLineID.cpp : implementation file
//
#include "stdafx.h" #include "stdafx.h"
#include "SetSaveLineID.h" #include "SetSaveLineID.h"
#include "afxdialogex.h"
#include <iostream>
#include <cstdio>
#include <regex>
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
#undef THIS_FILE #undef THIS_FILE
static char THIS_FILE[] = __FILE__; static char THIS_FILE[] = __FILE__;
#endif #endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CSetSaveLineID dialog // CSetSaveLineID dialog
@ -45,6 +46,8 @@ void CSetSaveLineID::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_EDIT_LHGT, m_LineHgt); DDX_Text(pDX, IDC_EDIT_LHGT, m_LineHgt);
//}}AFX_DATA_MAP //}}AFX_DATA_MAP
DDX_Control(pDX, IDC_COMBO_LINECE, m_LineCE); DDX_Control(pDX, IDC_COMBO_LINECE, m_LineCE);
//DDV_MinMaxDouble(pDX, m_LineHgt, 0.001, 99999.999);
DDX_Control(pDX, IDC_EDIT_LHGT, heightEdit);
} }
@ -54,6 +57,7 @@ BEGIN_MESSAGE_MAP(CSetSaveLineID, CBCGPDialog)
//}}AFX_MSG_MAP //}}AFX_MSG_MAP
ON_BN_CLICKED(IDOK, CSetSaveLineID::OnBnClickedOk) ON_BN_CLICKED(IDOK, CSetSaveLineID::OnBnClickedOk)
//ON_BN_CLICKED(IDC_RADIO3, &CSetSaveLineID::OnBnClickedRadio3) //ON_BN_CLICKED(IDC_RADIO3, &CSetSaveLineID::OnBnClickedRadio3)
// ON_EN_CHANGE(IDC_EDIT_LHGT, &CSetSaveLineID::OnEnChangeEditLhgt)
END_MESSAGE_MAP() END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -144,6 +148,18 @@ void CSetSaveLineID::OnBnClickedOk()
m_designLineID = GetLineID(); m_designLineID = GetLineID();
m_bClosedLine = m_LineCE.GetCurSel(); m_bClosedLine = m_LineCE.GetCurSel();
// 判断高度输入是否有效. 整数部分不超过5位数小数点后1-3位正数
string str = "^\\d{0,5}(\\.\\d{1,2})?$";
regex heightCheck(str);
CString strHeight;
heightEdit.GetWindowTextA(strHeight);
char* temp = strHeight.GetBuffer(strHeight.GetLength());
string asHeight = temp;
bool isNumber = regex_match(asHeight,heightCheck);
if(!isNumber){
BCGPMessageBox("高度设置不合法请输入0-99999.99之间的数字");
return;
}
CBCGPDialog::OnOK(); CBCGPDialog::OnOK();
} }

@ -6,9 +6,12 @@
#endif // _MSC_VER > 1000 #endif // _MSC_VER > 1000
// SetSaveLineID.h : header file // SetSaveLineID.h : header file
// //
#include "Resource.h"
#include "Globe.h" #include "Globe.h"
#include "resource.h"
#include "afxwin.h" #include "afxwin.h"
#include "angle.h"
#include <regex>
#include <string>
class CSetSaveLineID : public CBCGPDialog class CSetSaveLineID : public CBCGPDialog
{ {
@ -59,8 +62,12 @@ private:
bool m_bCheck; bool m_bCheck;
int GetLineID();//»ñÈ¡º½ÏßID int GetLineID();//»ñÈ¡º½ÏßID
public: public:
CBCGPComboBox m_LineCE; CBCGPComboBox m_LineCE;
// afx_msg void OnEnChangeEditLhgt();
// 航线高度文本框
CEdit heightEdit;
}; };
//{{AFX_INSERT_LOCATION}} //{{AFX_INSERT_LOCATION}}

Loading…
Cancel
Save