void CXTPSyntaxEditLexCfgFileReader::WriteProp(CFile& file, CString& csOffset, const XTP_EDIT_LEXPROPINFO& oldInfoProp, const XTP_EDIT_LEXPROPINFO& newInfoProp, const CStringArray& arBuffer)
{
	if (oldInfoProp.nLine < arBuffer.GetSize())
	{
		CString csBuffer = arBuffer[oldInfoProp.nLine];

		int iIndex = csBuffer.Find(_T("="));
		ASSERT(iIndex > 0);
		if (iIndex > 0)
		{
			csOffset = csBuffer.SpanIncluding(_T(" \t"));

			CString csSep = csBuffer.Mid(iIndex+1);
			csSep = csSep.SpanIncluding(_T(" \t"));
			iIndex += csSep.GetLength();

			CString csNewBuffer = csBuffer;
			csNewBuffer.Delete(iIndex+1, oldInfoProp.nPropertyLen);

			CString csPropValue = AfxMakeStrES(newInfoProp.arPropValue, _T(", "));
			csNewBuffer.Insert(iIndex+1, csPropValue);
			WriteString(file, csNewBuffer);
			return;
		}
	}
	else
	{
		ASSERT(FALSE);
	}

	WriteProp(file, csOffset, newInfoProp);
}
Ejemplo n.º 2
0
BOOL ICF_ifstream::ExtractFirstIntVersion(CString& string, int& number)
{
	const CString backup_string = string;
	CString substring;
	int pos;

	number = 0;

	if ((pos = string.FindOneOf("1234567890")) == -1)
	{
		ErrorMessage("File is improperly formatted.  Expected an "
			"integer value.");
		return FALSE;
	}

	// Cleave off everything before the first number.
	string = string.Right(string.GetLength() - pos);

	substring = string.SpanIncluding("1234567890"); // get the int as a string
	string = string.Right(string.GetLength() - substring.GetLength());

	number = atoi( (LPCTSTR)substring );

	// Prepare string for further processing.  Eat whitespace.
	string.TrimLeft();

	// If there's a trailing comma, eat it.
	if (!string.IsEmpty() && string.GetAt(0) == ',')
		string = string.Right(string.GetLength() - 1);

	// Eat any space following the comma.
	string.TrimLeft();

	return TRUE;
}
Ejemplo n.º 3
0
//
// Extracts the first solid series of letters, numbers, underscores, and
// hyphens in a string.  Returns the substring, removes the token from the
// original string.
//
// If spaces parameter is TRUE, spaces are considered part of the token
// instead of delimiters.
//
// Error condition is not reported.  If returned string is empty (IsEmpty)
// and an empty string is not expected, the caller should report an error.
//
CString ICF_ifstream::ExtractFirstToken(CString& string, BOOL spaces/*=FALSE*/)
{
	CString substring;
	int pos;
	CString token_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
							"abcdefghijklmnopqrstuvwxyz"
							"1234567890"
							"`~!@#$%^&*()-_=+[]{}\\:;\"'./<>?";


	if (spaces)
		token_chars += " ";

	if ((pos = string.FindOneOf(token_chars)) == -1)
	{
		substring.Empty();
		return substring;
	}

	string = string.Right(string.GetLength() - pos);

	substring = string.SpanIncluding(token_chars);

	string = string.Right(string.GetLength() - substring.GetLength());
	string.TrimLeft();
	string.TrimRight();

	return substring;
}
//销毁编辑框//
void COldConfigGraChiDlg::distroyEdit(CListCtrl *list, CEdit* distroyedit, int &Item, int &SubItem)
{
	CString strEditData;
	distroyedit->GetWindowText(strEditData);
	strEditData = strEditData.Trim();

	if (strEditData.IsEmpty())             //如果输入为空,则销毁编辑框//
	{
		distroyedit->DestroyWindow();
		if (m_vectConfigPara[Item].m_DefaultValue!=-3001)
		{
			m_vectConfigPara[Item].m_DefaultValue = -3001;
			m_bIsParaValueChange = true;
		}
		list->SetItemText(Item, 3, _T(""));
		return;
	}
	if (strEditData == strEditData.SpanIncluding(_T("0123456789.")))
	{
		float tempfloat = (float)_wtof(strEditData);
		strEditData.Format(_T("%.2f"), tempfloat);
		list->SetItemText(Item, 3, strEditData);                 //将修改写入列表框//
		if (tempfloat != m_vectConfigPara[Item].m_DefaultValue)  //判断值是否发生了变化//
		{
			m_vectConfigPara[Item].m_DefaultValue = tempfloat;    //将修改后的值存入容器//
			m_bIsParaValueChange = true;
		}
		
	}
	else
		AfxMessageBox(_T("非法操作,请输入数字!"));
	distroyedit->DestroyWindow();                          //销毁对象//
}
Ejemplo n.º 5
0
int CPopupEdit::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{	
	ASSERT(NULL != lpCreateStruct);

	if (-1 == CEdit::OnCreate(lpCreateStruct))
		return -1;

	if (m_bIsEmbeddedIntoListCtrl) {
		CWnd *Parent = GetParent();
		ASSERT_VALID(Parent);

		CFont *Font = Parent->GetFont();
		ASSERT_VALID(Font);

		SetFont(Font);
		SetWindowText(m_sInitText);
		SetFocus();

		CString Temp = m_sInitText.Right(1);
		if ((Temp.SpanIncluding("kKmMgG")).IsEmpty())
			SetSel(0, -1);
		else
			SetSel(0, m_sInitText.GetLength() - 1);
	}

	return 0;	
}
Ejemplo n.º 6
0
bool CFloatEdit::Validate() {
    CString text;
    this->GetWindowTextA(text);
    text.Trim();
    // empty string
    if(text.IsEmpty()) {
        return false;
    }
    // there is at least one number
    if(text.FindOneOf("0123456789") == -1) {
        return false;
    }
    // character besides digits or period?
    if(text.SpanIncluding("0123456789.-") != text) {
        return false;
    }
    // minus sign is not only in the first spot. implies only one minus sign
    if(text.ReverseFind('-') > 0) {
        return false;
    }
    // more than one period?
    if(text.Remove('.') > 1) {
        return false;
    }
    return true;
}
//销毁编辑框//
void CNewConfigGraChiDlg::distroyEdit(CListCtrl *list, CEdit* distroyedit, int &Item, int &SubItem)
{
    CString strEditData;
    float tempfloat;
    int nTempData;
    distroyedit->GetWindowText(strEditData);
    strEditData = strEditData.Trim();
    if (strEditData.IsEmpty())             //如果输入为空,则销毁编辑框//
    {
        distroyedit->DestroyWindow();
        m_vectList2[Item].m_fSetValue = -3001;
        list->SetItemText(Item, 3, _T(""));
        return;
    }
    if (m_vectList2[Item].m_ValueType == 0 && (strEditData != _T("0") && strEditData != _T("1")))
    {
        AfxMessageBox(_T("非法操作,该参数值只能为“0”或“1”!"));
        distroyedit->DestroyWindow();                          //销毁对象//
        return;
    }
    if (strEditData == strEditData.SpanIncluding(_T("0123456789.")))
    {
        switch (m_vectList2[Item].m_ValueType)
        {
        case 0:
            if (strEditData==_T("0"))
            {
                m_vectList2[Item].m_fSetValue = 0;
                list->SetItemText(Item, 3, _T("0"));
            }
            else
            {
                m_vectList2[Item].m_fSetValue = 1;
                list->SetItemText(Item, 3, _T("1"));
            }
            break;
        case 1:
        case 2:
        case 3:
            nTempData = (float)_wtof(strEditData);
            m_vectList2[Item].m_fSetValue = nTempData;    //将修改后的值存入容器//
            strEditData.Format(_T("%d"), nTempData);
            list->SetItemText(Item, 3, strEditData);      //将修改写入列表框//
            break;
        case 4:
        case 5:
            tempfloat = (float)_wtof(strEditData);
            strEditData.Format(_T("%.2f"), tempfloat);
            list->SetItemText(Item, 3, strEditData);      //将修改写入列表框//
            m_vectList2[Item].m_fSetValue = tempfloat;    //将修改后的值存入容器//
            break;
        default:
            break;
        }
    }
    else
        AfxMessageBox(_T("非法操作,请输入数字!"));
    distroyedit->DestroyWindow();                          //销毁对象//
}
Ejemplo n.º 8
0
void CPopupEdit::OnKillFocus(CWnd* pNewWnd) 
{
	CEdit::OnKillFocus(pNewWnd);

	CString Text;
	GetWindowText(Text);

	if (Text != "INFINITY") {
		if (!atoi(Text)) {
			SetWindowText(m_sInitText);
			GetWindowText(Text);
		}

		Text.Format("%d", atoi(Text));

		CString Temp;
		GetWindowText(Temp);
		Temp = Temp.Right(1);
				
		if (!Temp.SpanIncluding("kKmMgG").IsEmpty())
			Text.Format("%s%s", LPCTSTR(Text), LPCTSTR(Temp));

		CString OldText;
		GetWindowText(OldText) ;
		if (GetModify() || OldText != Text)
			SetWindowText(Text);
	}

	if (m_bIsEmbeddedIntoListCtrl) {
		CWnd *Parent = GetParent();
		ASSERT_VALID(Parent);

		CString str;
		GetWindowText(str);

		LV_DISPINFO dispinfo;
		dispinfo.hdr.hwndFrom  = Parent->m_hWnd;
		dispinfo.hdr.idFrom    = GetDlgCtrlID();
		dispinfo.hdr.code      = LVN_ENDLABELEDIT;

		dispinfo.item.mask     = LVIF_TEXT;
		dispinfo.item.iItem    = m_iItem;
		dispinfo.item.iSubItem = m_iSubItem;

		if (m_bESC) {
			dispinfo.item.pszText    = NULL;
			dispinfo.item.cchTextMax = 0;
		}
		else {
			dispinfo.item.pszText    = const_cast<LPTSTR>((LPCTSTR) str);
			dispinfo.item.cchTextMax = str.GetLength();
		}

		CWnd *ParentParent = Parent->GetParent();
		ASSERT_VALID(ParentParent);
		ParentParent->SendMessage(WM_NOTIFY, Parent->GetDlgCtrlID(), LPARAM(&dispinfo));
		DestroyWindow();
	}
}
Ejemplo n.º 9
0
//
// See if every character in the filename is a valid filename character.
//
BOOL CGalileoCmdLine::IsValidFilename(const CString & instring)
{
	const CString legal = "abcdefghijklmnopqrstuvwxyz1234567890_-=+!&%@#$.,;:'[]{}()\\ ";
	CString teststring = instring;

	teststring.MakeLower();

	return instring.GetLength() == teststring.SpanIncluding(legal).GetLength();
}
//销毁编辑框//
void CNewConfigGraChiDlg::distroyEdit(CListCtrl *list, CEdit* distroyedit, int &Item, int &SubItem)
{
	CString strEditData;
	distroyedit->GetWindowText(strEditData);
	strEditData = strEditData.Trim();
	if (strEditData.IsEmpty())             //如果输入为空,则销毁编辑框//
	{
		distroyedit->DestroyWindow();
		m_vectList2[Item].m_fSetValue = -3001;
		list->SetItemText(Item, 3, _T(""));
		return;
	}
	if (strEditData == strEditData.SpanIncluding(_T("0123456789.")))
	{
		list->SetItemText(Item, 3, strEditData);      //将修改写入列表框//
		float tempfloat = (float)_wtof(strEditData);
		m_vectList2[Item].m_fSetValue = tempfloat;    //将修改后的值存入容器//
	}
	else
		AfxMessageBox(_T("非法操作,请输入数字!"));
	distroyedit->DestroyWindow();                          //销毁对象//
}
void CDeviceChiDlg::distroyEdit(CListCtrl *list, CEdit* distroyedit, int &Item, int &SubItem)
{
	CString strEditData;
	distroyedit->GetWindowText(strEditData);
	strEditData = strEditData.Trim();
	if (strEditData.IsEmpty())             //如果输入为空,则销毁编辑框//
	{
		AfxMessageBox(_T("非法操作,输入不能为空!"));
		distroyedit->DestroyWindow();
		return;
	}
	if (strEditData == strEditData.SpanIncluding(_T("0123456789.")))
	{
		if(IDYES==MessageBox(_T("是否保存该修改?"), _T("提示"), MB_ICONQUESTION | MB_YESNO))
		{
			list->SetItemText(Item, 4, strEditData);      //将修改写入列表框//
			//待添加,将修改写入PLC//

		}
	}             
	else
		AfxMessageBox(_T("非法操作,请输入数字!"));
	distroyedit->DestroyWindow();                          //销毁对象//
}
Ejemplo n.º 12
0
//
// See if every character in the filename is valid as part of an integer.
//
BOOL CGalileoCmdLine::IsValidInteger(const CString & instring)
{
	const CString legal = "1234567890";

	return instring.GetLength() == instring.SpanIncluding(legal).GetLength();
}
//销毁编辑框//
void COldConfigGraChiDlg::distroyEdit(CListCtrl *list, CEdit* distroyedit, int &Item, int &SubItem)
{
    CString strEditData;
    float tempfloat;
    int tempValue;
    distroyedit->GetWindowText(strEditData);
    strEditData = strEditData.Trim();
    int nDataType = m_pDataProvider->searchModuleParaType(m_vectConfigPara[Item].m_ProcessParaId);
    if (strEditData.IsEmpty())             //如果输入为空,则销毁编辑框//
    {
        distroyedit->DestroyWindow();
        if (m_vectConfigPara[Item].m_DefaultValue!=-3001)
        {
            m_vectConfigPara[Item].m_DefaultValue = -3001;
            m_bIsParaValueChange = true;
        }
        list->SetItemText(Item, 3, _T(""));
        return;
    }
    if ( nDataType== 0 && (strEditData != _T("0") && strEditData != _T("1")))
    {
        AfxMessageBox(_T("非法操作,该参数值只能为“0”或“1”!"));
        distroyedit->DestroyWindow();                          //销毁对象//
        return;
    }

    if (strEditData == strEditData.SpanIncluding(_T("0123456789.")))
    {
        switch (nDataType)
        {
        case 0:
            if (strEditData == _T("0"))
            {
                list->SetItemText(Item, 3, _T("0"));                 //将修改写入列表框//
                if (m_vectConfigPara[Item].m_DefaultValue != 0)
                {
                    m_vectConfigPara[Item].m_DefaultValue = 0;
                    m_bIsParaValueChange = true;
                }
            }
            else
            {
                list->SetItemText(Item, 3, _T("1"));                 //将修改写入列表框//
                if (m_vectConfigPara[Item].m_DefaultValue != 1)
                {
                    m_vectConfigPara[Item].m_DefaultValue = 1;
                    m_bIsParaValueChange = true;
                }
            }
            break;
        case 1:
        case 2:
        case 3:
            tempValue = (float)_wtof(strEditData);
            strEditData.Format(_T("%d"), tempValue);
            list->SetItemText(Item, 3, strEditData);
            if (tempValue != ((int)m_vectConfigPara[Item].m_DefaultValue))
            {
                m_vectConfigPara[Item].m_DefaultValue = tempValue;
                m_bIsParaValueChange = true;
            }
            break;
        case 4:
        case 5:
            tempfloat = (float)_wtof(strEditData);
            strEditData.Format(_T("%.2f"), tempfloat);
            list->SetItemText(Item, 3, strEditData);
            if (tempfloat != m_vectConfigPara[Item].m_DefaultValue)  //判断值是否发生了变化//
            {
                m_vectConfigPara[Item].m_DefaultValue = tempfloat;    //将修改后的值存入容器//
                m_bIsParaValueChange = true;
            }
            break;
        default:
            break;
        }
    }
    else
        AfxMessageBox(_T("非法操作,请输入数字!"));
    distroyedit->DestroyWindow();                          //销毁对象//
}
Ejemplo n.º 14
0
void CDialog_Check::OnBnClickedBtbSave()
{
	// TODO: 在此添加控件通知处理程序代码
	m_date.m_material = m_allMaterial.at(m_mName_ctrl.GetCurSel());
	if(m_date.m_material.GetId().empty())
	{
		CRuntimeMessageBox::RunMessageBox("请选择正确的材料");

		return;
	}
	CString tmp;
	m_mNum_ctrl.GetWindowText(tmp);
	if(tmp.IsEmpty() || tmp.SpanIncluding(_T("1234567890")) != tmp)
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的数目!");

		return;
	}
	else
	{
		m_date.m_num = atoi((const char *)tmp.GetBuffer(tmp.GetLength()));
		double price = atof(m_dateChange.CStringtostring(m_date.m_material.m_price).c_str());
		tmp.Format(_T("%.2lf"),m_date.m_num * price);
		m_total_ctrl.SetWindowText(tmp);
		m_date.m_total = price;
	}
	m_wName_ctrl.GetWindowText(m_date.m_operateWare);
	if(m_date.m_operateWare.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的仓库");

		return;
	}

	m_date.m_class = m_allClass.at(m_cName_ctrl.GetCurSel());
	if(m_date.m_class.GetId().empty())
	{
		CRuntimeMessageBox::RunMessageBox("请选择正确的部门名称");

		return;
	}
	m_date.m_userInfo = m_allUser.at(m_pName_ctrl.GetCurSel());
	if(m_date.m_userInfo.GetId().empty())
	{
		if(m_checkModal)
			CRuntimeMessageBox::RunMessageBox("请输入正确的入库人员");
		else
			CRuntimeMessageBox::RunMessageBox("请输入正确的出库人员");

		return;
	}
	m_telPhone_ctrl.GetWindowText(m_date.m_tellPhone);
	if(m_date.m_tellPhone.IsEmpty())
	{
		CRuntimeMessageBox::RunMessageBox("请输入正确的电话号码");

		return;
	}
	m_detail_ctrl.GetWindowText(m_date.m_detail);

	m_date.m_checkModal = m_checkModal;

	CControl_check tmpc;

	int haveNum = tmpc.VerCheckMaterial(m_date.m_material.GetId()) ;
	if( !m_checkModal && haveNum < m_date.m_num)
	{
		CRuntimeMessageBox::RunMessageBox("保存失败:此材料库存不足,无法出库!");

		return;
	}
	else if( !m_checkModal)
	{
		m_date.m_num -= haveNum;
	}
	else
	{
		m_date.m_num += haveNum;
	}

	tmpc.SetData(&m_date);
	if (tmpc.Save())
	{
		CRuntimeMessageBox::RunMessageBox("保存成功!");

		OnOK();
	}
	else
	{
		CRuntimeMessageBox::RunMessageBox("保存失败!");
	}
}
LRESULT CObjectProperty::OnGetControl (WPARAM wParam, LPARAM lParam )
{


    sItem* pEdit = ( sItem* ) lParam;

    if ( pEdit->iGroup >= (int)m_pGroups.size ( ) )
        return 0;

    CBCGProp*  pProp = m_pGroups [ pEdit->iGroup ].pProperty;

    if ( !pProp )
        return 0;

    if ( pEdit->iControl >= pProp->GetSubItemsCount() )
        return 0;

    CBCGProp* pControl = pProp->GetSubItem ( pEdit->iControl );

    if ( !pControl )
        return 0;

    if ( wParam == 0 )
    {
        // name
        pEdit->name = pControl->m_strName;
    }
    else if ( wParam == 1 )
    {
        CString string = ( LPCTSTR ) ( _bstr_t ) pControl->m_varValue;

        // contents
        pEdit->contents = string;

        if ( pControl->IsKindOf ( RUNTIME_CLASS ( CBCGColorProp ) ) )
        {
            CBCGColorProp* pColor = ( CBCGColorProp* ) pControl;

            COLORREF color = pColor->GetColor ( );

            TCHAR test [ 256 ] = _T("");

            int iRed   = GetRValue ( color );
            int iGreen = GetGValue ( color );
            int iBlue  = GetBValue ( color );

            wsprintf ( test, _T ( "%d %d %d" ),iRed, iGreen, iBlue );

            pEdit->contents = test;
        }

        else if ( pControl->IsKindOf ( RUNTIME_CLASS ( CBCGFileProp ) ) )
        {

            CBCGFileProp* pFileEx = ( CBCGFileProp* ) pControl;

            char szContentsANSI [ 255 ]	= "";
            char szDirANSI      [ 255 ]	= "";
            char szExcludeANSI  [ 255 ]	= "";

            CString a = string.SpanIncluding( pControl->m_FPSCDir );

            if ( a.GetLength ( ) >= pControl->m_FPSCDir.GetLength ( ) )
            {


                int a =  pControl->m_FPSCDir.GetLength ( );
                int b =  string.GetLength ( );

                CString strBang = string.Right( b - a );


                ConvertWideToANSI ( NULL, &string,              szContentsANSI );
                ConvertWideToANSI ( NULL, &pControl->m_FPSCDir, szDirANSI );
                ConvertWideToANSI ( NULL, &strBang, szExcludeANSI );

                int c = 0;

                //if ( !strBang.IsEmpty ( ) )
                {
                    pControl->SetValue((_variant_t)strBang);
                }


                pEdit->contents = strBang;

            }
        }

    }
    else if ( wParam == 2 )
    {
        // description
        pEdit->description = pControl->m_strDescr;
    }
    else
    {
        // failure
    }
    return 0;
}
Ejemplo n.º 16
0
BOOL CTokenFileInfo::CheckForInclude()
  {
  if (bUseIncludes && (pParser->sTokenLine[0]==sIncludeChars[0]))
    {
    CString FileName = pParser->sTokenLine;
    if (pParser->sTokenLine.Find((const char*)sIncludeChars)==0)
      {
      FileName = FileName.Mid(sIncludeChars.GetLength(), 1024);
      FileName = FileName.Right(FileName.GetLength() - FileName.SpanIncluding(" \t").GetLength());
      while (FileName.GetLength()>0 && (FileName[FileName.GetLength()-1]==' ' || FileName[FileName.GetLength()-1]=='\t'))
        FileName = FileName.Left(FileName.GetLength()-1);
      BOOL Failed = TRUE;
      DWORD ErrNo = 1;//file not specified
      if (FileName.GetLength()>0)
        {
        if (FileName[0]=='\'' || FileName[0]=='"')
          FileName = FileName.Right(FileName.GetLength() - 1);
        int len = FileName.GetLength();
        if (len>0)
          {
          if (FileName[len-1]=='\'' || FileName[len-1] == '"')
            FileName = FileName.Left(len-1);
          len = FileName.GetLength();
          if (len>0)
            {
            iFileIndex++;
            if (iFileIndex<TP_MaxIncludeFiles)
              {
              Strng Fn, FnFull;
              Fn.FnDrivePath((char*)(const char*)FileName);
              if (Fn()==NULL)
                {// No Path Use Previous
                Fn.FnDrivePath((char*)(const char*)FileNames[iFileIndex-1]);
                Fn+=(char*)(const char*)FileName;
//                FileName=Fn();
                }
              else
                Fn=(char*)(const char*)FileName;

              // CNM
              if ((Fn[0]=='~') || (Fn[0]=='.')) // relative filename ?
                { // yes - prepend current folder (defined by previously openned file - NOT O/S
                Strng T;
                T.FnDrivePath((LPTSTR)(LPCTSTR)AllFileNames[iIncFileCnt-1]);
                T+=Fn;
                Fn=T;
                }

              FnFull.FnSearchExpand(Fn(), bFnPlaces);

              Fn.FnContract();
              FileName=Fn();

              FileNames[iFileIndex] = Fn();
              pParser->wLineNo--;
              FileLineNo[iFileIndex] = 0;

              Failed = !OpenFile(FnFull);
              //File[iFileIndex] = fopen(FnFull(), "rt");

              FnModifyTime(FnFull(), FileTimes[iFileIndex]);
              if (iIncFileCnt<TP_MaxTtlIncludeFiles)
                {
                AllFileNames[iIncFileCnt]=Fn();
                AllFileTimes[iIncFileCnt]=FileTimes[iFileIndex];
                iIncFileCnt++;
                }

              if (Failed)
                ErrNo = 2;//cannot open file
              }
            else
              ErrNo = 3;//too many nested includes
            }
          }
        }
      if (Failed && pParser->pFailFn)
        {
        (*(pParser->pFailFn))((char*)(const char*)FileName, ErrNo, pParser->pFailExtraPtr);
        }
      return TRUE;
      }
    }
  return FALSE;
  }