//销毁编辑框//
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();                          //销毁对象//
}
Example #2
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();
}
Example #3
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();
}
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;
}