📄 boxleng.cpp
字号:
// BoxLeng.cpp : implementation file
//
#include "stdafx.h"
#include "LandSoft.h"
#include "BoxLeng.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBoxLeng dialog
CBoxLeng::CBoxLeng(CWnd* pParent,UINT maxlong)
: CDialog(CBoxLeng::IDD, pParent)
{
//{{AFX_DATA_INIT(CBoxLeng)
m_Boxleng = _T("");
//}}AFX_DATA_INIT
m_nMaxlong=maxlong;
}
void CBoxLeng::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBoxLeng)
DDX_Text(pDX, IDC_EDIT_BOXLENG, m_Boxleng);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBoxLeng, CDialog)
//{{AFX_MSG_MAP(CBoxLeng)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBoxLeng message handlers
void CBoxLeng::OnOK()
{
UpdateData(TRUE);
m_Boxleng.TrimLeft();
CString tmpstr="";
UINT tmpleng;
UINT prevleng=0;
char tmp;
m_Lengs.RemoveAll();
for(int i=0;i<m_Boxleng.GetLength();i++)
{
tmp=m_Boxleng.GetAt(i);
if(tmp>47&&tmp<58)
{
tmpstr+=tmp;
continue;
}
else if(tmp==32)
{
if(m_Boxleng.GetAt(i-1)!=32)
{
tmpleng=atoi(tmpstr);
if(tmpleng<1||tmpleng>m_nMaxlong)
{
AfxMessageBox("你输入的值必须大于0,小于图像长度。",MB_OK,NULL);
return;
}
if(tmpleng<=prevleng)
{
AfxMessageBox("你应当从小到大输入, 且不能相等!",MB_OK,NULL);
return;
}
prevleng=tmpleng;
m_Lengs.Add(tmpleng);
tmpstr="";
}
continue;
}
else
{
AfxMessageBox("你输入了非法字符,请重新输入!",MB_OK,NULL);
return;
}
}
if(tmp>47&&tmp<58)
{
tmpleng=atoi(tmpstr);
if(tmpleng<1||tmpleng>m_nMaxlong)
{
AfxMessageBox("你输入的值必须大于0,小于图像长度。",MB_OK,NULL);
return;
}
if(tmpleng<=prevleng)
{
AfxMessageBox("你应当从小到大输入, 且不能相等!",MB_OK,NULL);
return;
}
m_Lengs.Add(tmpleng);
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -