Beispiel #1
0
void CHHMRModParam::OnChangeModparamsSaveLoc() 
{
	CString Text;
	GetDlgItemText(IDC_HHMRMODPARAMS_SAVELOC,Text);
	if (!Text.IsEmpty())
	{
		int posStart, posEnd;
		((CEdit*)GetDlgItem(IDC_HHMRMODPARAMS_SAVELOC))->GetSel(posStart,posEnd);
		if (Text.FindOneOf(INVALIDCHARSSUB) != -1)
		{
			((CEdit*)GetDlgItem(IDC_HHMRMODPARAMS_SAVELOC))->Undo();
			posStart--;
			posEnd--;
		}
		((CEdit*)GetDlgItem(IDC_HHMRMODPARAMS_SAVELOC))->SetModify(FALSE);
		((CEdit*)GetDlgItem(IDC_HHMRMODPARAMS_SAVELOC))->EmptyUndoBuffer();
		((CEdit*)GetDlgItem(IDC_HHMRMODPARAMS_SAVELOC))->SetSel(posStart,posEnd);
	}

	if (m_pPS)m_pPS->SetToClose(0);

	if (!m_bCollectingParametersForNewISO)
	{
		m_bChange = true;
		m_pApplyButton->EnableWindow(TRUE);
	}
}
//
// 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;
}
Beispiel #3
0
BOOL CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(":/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				int iStart = 0;
				newName += strExt.Tokenize(_T(";"), iStart);
			}
		}

		if (!AfxGetApp()->DoPromptFileName(newName,
		  bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
		  OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE(traceAppMsg, 0, "Warning: failed to delete file after failed SaveAs.\n");
				DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}
		return FALSE;
	}
Beispiel #4
0
static void SplitString(const CString & str, CMediaInfoList & list)
{
  int tokenPos = 0;
  CString token;
  while (!(token = str.Tokenize(L"\n", tokenPos)).IsEmpty()) {
    CMediaInfo info;

    int colon = token.Find(':');
    if (colon < 0)
      info = token;
    else {
      info = token.Left(colon);

      int equal = token.FindOneOf(L"#=");
      if (equal < 0)
        info.m_options[token.Mid(colon+1)] = CMediaInfo::OptionInfo();
      else
        info.m_options[token.Mid(colon+1, equal-colon-1)] = CMediaInfo::OptionInfo(token.Mid(equal+1), token[equal] == '#');
    }

    CMediaInfoList::iterator iter = std::find(list.begin(), list.end(), info);
    if (iter == list.end())
      list.push_back(info);
    else if (!info.m_options.empty())
      iter->m_options[info.m_options.begin()->first] = info.m_options.begin()->second;
  }
}
Beispiel #5
0
// Static Routines
static void ValidateProfileName(const CString& profileName, CDataExchange* pDX)
{
    USES_CONVERSION;

    nsresult rv;
    PRBool exists = FALSE;

    {
        nsCOMPtr<nsIProfile> profileService = 
                 do_GetService(NS_PROFILE_CONTRACTID, &rv);
        rv = profileService->ProfileExists(T2CW(profileName), &exists);
    }

    if (NS_SUCCEEDED(rv) && exists)
    {
        CString errMsg;
        errMsg.Format(_T("Error: A profile named \"%s\" already exists."), profileName);
        AfxMessageBox( errMsg, MB_ICONEXCLAMATION );
        errMsg.Empty();
        pDX->Fail();
    }

    if (profileName.FindOneOf(_T("\\/")) != -1)
    {
        AfxMessageBox( _T("Error: A profile name cannot contain the characters \"\\\" or \"/\"."), MB_ICONEXCLAMATION );
        pDX->Fail();
    }
}
//************************************************************************************
BOOL CBCGPOutlineParser::Compare (const CString& strBuffer, const int nBufferOffset,
								  const CString& strCompareWith, int& nEndOffset) const
{
	// Returns equal chars num:
	const int nLength = strCompareWith.GetLength ();
	const int nBufLength = strBuffer.GetLength ();
	int i = 0;

	for (i = 0; i < nLength && nBufferOffset + i < nBufLength; i++)
	{
		if (m_bCaseSensitive ? 
			(strCompareWith [i] != strBuffer [nBufferOffset + i]) :
			(_tcsnicmp (((LPCTSTR) strCompareWith) + i, 
						((LPCTSTR) strBuffer) + nBufferOffset + i, 1) != 0))
		{
			nEndOffset = nBufferOffset;
			return FALSE;
		}
	}

	if (m_bWholeWords && strCompareWith.FindOneOf (m_strDelimiters) == -1)
	{
		if ((nBufferOffset > 0 &&
			 m_strDelimiters.Find (strBuffer [nBufferOffset - 1]) == -1) ||
			(nBufferOffset + i < nBufLength &&
			 m_strDelimiters.Find (strBuffer [nBufferOffset + i]) == -1))
		{
			nEndOffset = nBufferOffset;
			return FALSE;
		}
	}

	nEndOffset = nBufferOffset + i - 1;
	return (i > 0) && (i == nLength);
}
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;
}
// Get a attribute value from an attribute name
bool CNetList::get_attr( int file_name_index, int sheet, CNetListSymbol &symbol, CString attr, CString &r )
{
	CDrawMethod* pMethod = symbol.m_pMethod;
	if (attr.CompareNoCase( _T("refnum") ) == 0)
	{
		// Use the reference number (minus the reference character)
		CString s = pMethod->GetRefSheet(m_prefix_references,m_prefix_import,file_name_index,sheet+1);
		int b = s.FindOneOf(_T("0123456789"));
		if (b != 1)
		{
			r = s;
			return true;
		}
		else
		{
			r = s.Mid(b);
			return true;
		}
	}
	else
	{
		for (int j = 0; j < pMethod->GetFieldCount(); j++)
		{
			if (pMethod->GetFieldName(j).CompareNoCase(attr) == 0)
			{
				r = pMethod->GetField(j);
				return true;
			}
		}
	}

	return false;
}
Beispiel #9
0
//=========================================================
// DTVの可能性のあるファイルかどうか直接確認する
//=========================================================
bool CArchiverJACK::ExamineArchive(LPCTSTR ArcFileName,CConfigManager& ConfMan,bool,bool &bInFolder,bool &bSafeArchive,CString &BaseDir,CString &strErr)
{
	bInFolder=false;
	bSafeArchive=false;

	CString strFileName;

	//ファイルを読んで格納ファイル名を取得
	if(!GetContainedFileName(ArcFileName,strFileName))return false;
	if(-1==strFileName.FindOneOf(_T(":\\/"))){//パス指定の文字が含まれていないので安全
		bSafeArchive=true;
	}

/*
	このコードでは解凍するファイル、一つしかファイル内容を確認していない。
	これでも問題がない理由は、JACK32.dllは展開時に出力ファイル名の一貫性をチェックしている模様だからである。
	[流れ]
	・n-1番目までのファイルには細工がされていない
		・n番目のファイルも細工されていない
			→正常解凍、n++
		・n番目のファイルが細工されている
			・n-1番目までのファイルをLhaForgeに与えた
				→安全だとして解凍を始めたものの、JAKの同一性チェックにかかる
			・n番目のファイルをLhaForgeに与えた
				→LhaForgeのDTVチェックにかかる

	[注意点]
	現在のコードでは、上書き確認機能を使うとき、同じJAKファイルを2回読むことになる。
	効率を求めるなら、ここのコードを無効化して、Extract()内部で安全かどうかチェックするようにすればよい。
	いまのところは、効率よりも見通しの良さを優先している。
*/

	return true;
}
Beispiel #10
0
Datei: Loc.cpp Projekt: IcyX/bote
/// Funktion gibt einen String zurück, der in einer StringTable steht.
CString CLoc::GetString(const CString& key, BOOLEAN forceBigStarting, const CString& subString1, const CString& subString2)
{
	CString returnString;
	if (!m_StringTable.Lookup(key, returnString))
		return key + " is missing";

	// Haben wir subStrings übergeben, so müssen wir die § Zeichen ersetzen
	if (subString1 != "")
	{
		// hier ein bisl umständlich, aber sonst würde er alle "§" Zeichen ersetzen
		int pos = returnString.FindOneOf("§");
		if (pos != -1)
		{
			returnString.Delete(pos);
			returnString.Insert(pos,subString1);
			if (subString2 != "")
				returnString.Replace("§",subString2);
		}
	}
	if (forceBigStarting)
	{
		CString upper = (CString)returnString.GetAt(0);
		returnString.SetAt(0, upper.MakeUpper().GetAt(0));
	}
	return returnString;
}
Beispiel #11
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;
}
Beispiel #12
0
PRGINTERFACE_API void  DataIntegrateForCheck(CMapStringToString &mstr, int indexmax, bool colormark)
{
	CString perrecord;
	CString jherr("");
	int ipos = indexmax;

	zero = 0.0;
	if(mstr.Lookup(_T("Z19"),perrecord) && (perrecord.FindOneOf("0123456789") >= 0)){
		zero = atof(perrecord);
	}
	z14 = 0;
	if(mstr.Lookup(_T("Z14"),perrecord) && (perrecord.FindOneOf("0123456789") >= 0)){
		z14 = atoi(perrecord);
	}
	while(ipos-- > 0)
	{
		CString sid;
		double accuracy;
		sid.Format("Z%d",ipos);
		if(mstr.Lookup(sid,perrecord) && (perrecord.FindOneOf("0123456789") >= 0))
		{
			if(perrecord.Find("--") >= 0)
				continue;
			sid.Format("jhsel%d",INDEX2GROUP(ipos));
			if(!mstr.Lookup(sid,sid) || (sid.FindOneOf("0123456789") < 0) )		continue;//retrieve the jhsel
						
			accuracy = atof(sid)/100.0;
			
			int iid = CheckPrecious(sid);
			if(iid < 0)		continue;//translate the jhsel//translate the jhsel
			perrecord = DataIntergrate(ipos,atof(perrecord),g_PrecBase[iid].iDigipos-2,g_PrecBase[iid].iMantissa);
			if((!CheckData(ipos,atof(perrecord),accuracy)))
			{
				//add the a message to the error
				CString stmp;
				stmp.Format("%s盘第%d点不合格;\n",Panhao[INDEX2GROUP(ipos)],INDEX2REST(ipos));
				jherr += stmp;
				if(colormark)
					perrecord = "<font color='red'>"+perrecord+"</font>";
			}
			sid.Format("Z%d",ipos);
			mstr.SetAt(sid,perrecord);
		}

	}
	mstr.SetAt("jdjg",jherr);//检定结果
}
Beispiel #13
0
BOOL CKSFileDialog::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
{
	if (m_pDoc==NULL){ASSERT (FALSE);return FALSE;}
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = m_pDoc->GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_pDoc->GetPathName();
		if (bReplace && newName.IsEmpty())
		{
			newName = m_pDoc->GetTitle();
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				newName += strExt;
			}
		}

		if (DoPromptFileName(newName,bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
		  OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!m_pDoc->OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			try
			{
				CFile::Remove(newName);
			}
			catch( CException * e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				do { e->Delete(); } while (0);
			}
		}
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		m_pDoc->SetPathName(newName);

	return TRUE;        // success
}
static bool SearchFiles(CString mask, CAtlList<CString>& sl)
{
    if (mask.Find(_T("://")) >= 0) {
        return false;
    }

    mask.Trim();
    sl.RemoveAll();

    CMediaFormats& mf = AfxGetAppSettings().m_Formats;

    WIN32_FILE_ATTRIBUTE_DATA fad;
    bool fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
                             && (fad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
    if (fFilterKnownExts) {
        mask = CString(mask).TrimRight(_T("\\/")) + _T("\\*.*");
    }

    {
        CString dir = mask.Left(max(mask.ReverseFind('\\'), mask.ReverseFind('/')) + 1);

        WIN32_FIND_DATA fd;
        HANDLE h = FindFirstFile(mask, &fd);
        if (h != INVALID_HANDLE_VALUE) {
            do {
                if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                    continue;
                }

                CString fn = fd.cFileName;
                //CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
                CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
                CString path = dir + fd.cFileName;

                if (!fFilterKnownExts || mf.FindExt(ext)) {
                    for (size_t i = 0; i < mf.GetCount(); i++) {
                        CMediaFormatCategory& mfc = mf.GetAt(i);
                        /* playlist files are skipped when playing the contents of an entire directory */
                        if ((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(_T("pls")) != 0)) {
                            sl.AddTail(path);
                            break;
                        }
                    }
                }

            } while (FindNextFile(h, &fd));

            FindClose(h);

            if (sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1) {
                GetCDROMType(mask[0], sl);
            }
        }
    }

    return (sl.GetCount() > 1
            || sl.GetCount() == 1 && sl.GetHead().CompareNoCase(mask)
            || sl.GetCount() == 0 && mask.FindOneOf(_T("?*")) >= 0);
}
Beispiel #15
0
CString CSimpleSAH::GetAttribute(LPCSTR lpAttriName)
{
	CString tmp;
	CString tag(strCurTagBuf);
	tag.MakeLower();
	CString attri(lpAttriName);
	attri.MakeLower();

	try{

	CString s;
	int i=0, j=0;
	BOOL found = FALSE;
	while(!found)
	{
		i = tag.Find(attri, i);
		if(i<0)
			break;

		j = tag.Find('=', i);
		s = tag.Mid(i+attri.GetLength(), j-i-attri.GetLength());
		s.TrimLeft();
		if(s.IsEmpty())
		{
			found=TRUE;
			tmp = strCurTagBuf.Mid(j+1);
			if(tmp.GetAt(0) == '\"' || tmp.GetAt(0) == '\'') //quoted string
			{
				tmp = tmp.Right(tmp.GetLength()-1);
				i = tmp.FindOneOf("\'\"\r\n>");
			}
			else
				i = tmp.FindOneOf(" \r\n>\'\"");
			tmp = tmp.Left(i);
			tmp.TrimLeft();
			tmp.TrimRight();
		}
		i += attri.GetLength();
	}
	}
	catch(...)
	{
	}

	return tmp;
}
Beispiel #16
0
// modified from doccore.cpp
BOOL CBonfireDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				newName += strExt;
			}
		}

		if (SaveFileDialog(AfxGetMainWnd(),newName,newName,NULL,
			GetFileFilter(FILTER_FILES),6,GetDefExt(FILTER_FILES)) <= 0)
			return FALSE; // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				do { e->Delete(); } while (0); //DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}
		return FALSE;
	}
Beispiel #17
0
BOOL CStaticDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			if (newName.IsEmpty())
				VERIFY(newName.LoadString(AFX_IDS_UNTITLED));
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			newName += AfxGetStrategyFileExt( );
		}

		if( !AfxDoPromptFileName(newName, bReplace ? IDS_SAVEFILE : IDS_SAVEFILECOPY,
				OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING, FALSE ) )
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			try
			{
				CFile::Remove(newName);
			}
			catch(CException *e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				if( !e->m_bAutoDelete )
					e->Delete();
			}
		}
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		SetPathName(newName);

	return TRUE;        // success
}
/////////////////////////////////////////////////////////////////////////////
// check for a valid name
/////////////////////////////////////////////////////////////////////////////
void CConnectorRegisterDlg::validateName()
{
	int nResult;
	CString str;

	//get the name of the player
	str = m_player.getName();

	//check for a valid length
	if(CONNECTOR_NAME_MAX_LENGTH < str.GetLength())
	{
		MessageBox("The name you selected, " + str + ", is too long.  Please shorten it and try again.", "Sea3D Connector");
		return;
	}
	else if(-1 != str.FindOneOf("|'\""))
	{
		MessageBox("Your name may not contain any of the following characters: |, ', or \"", "Sea3D Connector");
		return;
	}

	//disable all except the frame and the status text
	enableStep1(FALSE);
	enableStep2(FALSE);

	//reneable frame and status text
	m_Step1Static.EnableWindow();
	m_NameStatusStatic.EnableWindow();

	//set the initial text
	m_NameStatusStatic.SetWindowText("Validating name...");
	
	//check it
	nResult = CONNECTOR->validateName(str);
	//see if it works
	if(TRUE == nResult)
	{
		//set the text
		m_NameStatusStatic.SetWindowText("Your name is available.");

		//move on
		enableStep1(FALSE);
		enableStep2(TRUE);
	}
	else if(-1 == nResult)
	{
		MessageBox("This player has been banned from ladder games.", "Sea3D Connector");
		EndDialog(IDCANCEL);
	}
	else
	{
		//set the text
		m_NameStatusStatic.SetWindowText("Your name is not available!");

		//they have to pick a new name
		enableStep1(TRUE);
	}
}
Beispiel #19
0
void COXUNC::Trim(CString& sText)
	// --- In  :
	// --- Out : 
	// --- Returns :
	// --- Effect : Removes invalid characters and leading and trailing spaces
	{
	// ... Remove invalid chars	<>|"
	int nInvalidCharPos = sText.FindOneOf(m_pszInvalidChars);
	while (0 <= nInvalidCharPos)
		{
		sText = sText.Left(nInvalidCharPos) + sText.Mid(nInvalidCharPos + 1);
		nInvalidCharPos = sText.FindOneOf(m_pszInvalidChars);
		}

	// ... Remove leading and trailng spaces
	sText.TrimLeft();
	sText.TrimRight();
	}
Beispiel #20
0
void CGridCellDateTime::Init(COleDateTime odt, LPCTSTR format)
{
	m_odt = odt;
	m_format = "%c";            // default to short date + time for locale
	CString strFormat = format;
	COleDateTime tmp(3333, 11, 22, 00, 44, 55);  // used for testing formatted dates
	CString strDate;            // temp date string

	// First check if it contains at least one format spec but not any disallowed specs
	if (strFormat.Find('%') != -1 && strFormat.FindOneOf("aAbBjuwWzZ") == -1)
	{
		// Remove any allowed specs that may create alphabetic chars (AM/PM indicator)
		strFormat.Replace("%p", "");
		strFormat.Replace("%c", "");
		strFormat.Replace("%X", "");
		strDate = tmp.Format(strFormat);

		// Now if there are any alphas left they are caused by disallowed format specs (such
		// as %#c) or there are literals characters that we don't like (would need quoting)
		if (strDate.FindOneOf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") == -1)
			m_format = format;
	}

	// This is nec. in case the user presses Esc key in which case the text saved here is compared
	// with initial edit text to see if anything has changed (and if GVN_ENDLABELEDIT mesg needed).
	SetText(m_odt.Format(m_format));

	// Now convert strftime format string to date-time control format string
	strDate = tmp.Format(m_format);
	strDate.Replace("AM", "tt");
	strDate.Replace("am", "tt");
	strDate.Replace("A", "tt");
	strDate.Replace("a", "tt");
	strDate.Replace("12", "hh");    // hour 00 may appear as 12
	strDate.Replace('3', 'y');
	strDate.Replace('1', 'M');
	strDate.Replace('2', 'd');
	strDate.Replace('0', 'h');
	strDate.Replace('4', 'm');
	strDate.Replace('5', 's');
	m_format = strDate;
}
BOOL CHMProject::HitTestSectionID(LPCSTR str)
{
    CString s;
    ASSERT(str!=NULL);
    s=str;
    s.TrimLeft();
    if (s.IsEmpty()) return FALSE;
    if ((s[0]=='[')&&(s.FindOneOf("]")>0))
        return TRUE;
    return FALSE;
}
void CAxialAnalysisOptionsDlg::OnUpdateRadius()
{
    CString text;
    GetDlgItem(IDC_RADIUS)->GetWindowText(text);
    if (!text.IsEmpty() && text.FindOneOf(_T("nN123456789")) == -1) {
        AfxMessageBox(_T("The radius must either be numeric or 'n'\n")
                      _T("Alternatively, for multiple radii, type a list of comma separated numeric radii (you can include 'n')"));
        GetDlgItem(IDC_RADIUS)->SetWindowText(_T("n"));
        m_radius_ctrl.SetFocus();
    }
}
/** 
 * @brief Convert user-given extension list to valid regular expression.
 * @param [in] Extension list/mask to convert to regular expression.
 * @return Regular expression that matches extension list.
 */
CString FileFilterHelper::ParseExtensions(CString extensions) const
{
	CString strParsed;
	CString strPattern;
	BOOL bFilterAdded = FALSE;
	static const TCHAR pszSeps[] = _T(" ;|,:");

	extensions += _T(";"); // Add one separator char to end
	int pos = extensions.FindOneOf(pszSeps);
	
	while (pos >= 0)
	{
		CString token = extensions.Left(pos); // Get first extension
		extensions.Delete(0, pos + 1); // Remove extension + separator
		
		// Only "*." or "*.something" allowed, other ignored
		if (token.GetLength() >= 2 && token[0] == '*' && token[1] == '.')
		{
			bFilterAdded = TRUE;
			strPattern += _T(".*\\.");
			strPattern += token.Mid(2);
			strPattern += _T("$");
		}
		else
			bFilterAdded = FALSE;

		pos = extensions.FindOneOf(pszSeps); 
		if (bFilterAdded && pos >= 0)
			strPattern += _T("|");
	}

	if (strPattern.IsEmpty())
		strParsed = _T(".*"); // Match everything
	else
	{
		strParsed = _T("^");
		strPattern.MakeLower();
		strParsed = strPattern; //+ _T("$");
	}
	return strParsed;
}
Beispiel #24
0
PRGINTERFACE_API void DataIntegrateForCompensate(CMapStringToString &mstr,int indexmax)
{
	CString perrecord;
	int ipos = indexmax;
	zero = 0.0;
	if(mstr.Lookup(_T("Z19"),perrecord) && (perrecord.FindOneOf("0123456789") >= 0)){
		zero = atof(perrecord);
	}
	z14 = 0;
	if(mstr.Lookup(_T("Z14"),perrecord) && (perrecord.FindOneOf("0123456789") >= 0)){
		z14 = atoi(perrecord);
	}
	
	while(ipos-- > 0)
	{
		CString sid;
		double accuracy;
		sid.Format("Z%d",ipos);
		if(mstr.Lookup(sid,perrecord) && (perrecord.FindOneOf("0123456789") >= 0))
		{
			if(perrecord.Find("--") >= 0)
				continue;
			sid.Format("jhsel%d",INDEX2GROUP(ipos));
			if(!mstr.Lookup(sid,sid) || sid.FindOneOf("0123456789") < 0)		continue;//retrieve the jhsel
			
			accuracy = atof(sid)/100.0;
			
			int iid = CheckPrecious(sid);
			if(iid < 0)		continue;//translate the jhsel
			perrecord = DataIntergrate(ipos,atof(perrecord),g_PrecBase[iid].iDigipos-2,g_PrecBase[iid].iMantissa);
			sid=SJD2SByPosition(GetDiffData(ipos,atof(perrecord),accuracy),INDEX2GROUP(ipos)+g_PrecBase[iid].iDigipos-3);
			if(!CheckData(ipos,atof(perrecord),accuracy))
			{
				sid = "<font color='red'>"+sid+"</font>";
			}
			perrecord = sid;
			sid.Format("Z%d",ipos);
			mstr.SetAt(sid,perrecord);
		}
	}
}
Beispiel #25
0
git_revnum_t CGit::GetHash(CString &friendname)
{
	CString cmd;
	CString out;
	cmd.Format(_T("git.exe rev-parse %s" ),friendname);
	Run(cmd,&out,CP_UTF8);
//	int pos=out.ReverseFind(_T('\n'));
	int pos=out.FindOneOf(_T("\r\n"));
	if(pos>0)
		return out.Left(pos);
	return out;
}
Beispiel #26
0
BOOL Utility::IsFileSearchPattern(CString sFileName)
{
	// Remove the "\\?\" prefix in case of a long path name
	if(sFileName.Left(4).Compare(_T("\\\\?\\"))==0)
		sFileName = sFileName.Mid(4);

	// Check if the file name is a search template.		
	BOOL bSearchPattern = FALSE;	
	int nPos = sFileName.FindOneOf(_T("*?"));
	if(nPos>=0)
		bSearchPattern = true;
	return bSearchPattern;
}
Beispiel #27
0
int CStaffSetDlg::GetNumFromString(CString strNum)
{
	if (strNum==_T(""))
	{
		return 0;
	}
	CString strRealNum;
	int nStartNumIndex = strNum.FindOneOf(_T("0123456789"));
	strRealNum = strNum.Mid(nStartNumIndex);
	char szbuf[32] = {0};
	CCommonConvert::WChar2Char(szbuf, 32, strRealNum.GetBuffer());
	int nMaxID = ::atoi(szbuf);
	return nMaxID;
}
Beispiel #28
0
MBASEAPI BOOL MIRACLEEXPORT TestIsValidForFileName(LPCTSTR name)
{
	if (strlen(name) == 0) 	
		return false;
	
	char invalidchars[25] = " :\\/%%.*?+,'^|&;é@`,<>";
	invalidchars[0] = 34; // Çift týrnak eklenir.


	CString str = name;
	if (str.FindOneOf(invalidchars) != -1)	
		return false;
	return true;
}
BOOL CCreateTPDownloadDlg::_CheckFileName(CDialog *pdlg, UINT nIdCtrl)
{
	CString str;
	pdlg->GetDlgItemText (nIdCtrl, str);
	LPCSTR pszInvChars = "\\/:*?\"<>|";
	if (str.FindOneOf (pszInvChars) != -1)
	{
		pdlg->MessageBox (LS (L_INVFILENAME), LS (L_INPERR), MB_ICONEXCLAMATION);
		pdlg->GetDlgItem (nIdCtrl)->SetFocus ();
		return FALSE;
	}

	return TRUE;
}
Beispiel #30
0
const reMrIndexType CartridgeFinder::reMsrIndex(CString strResult)
{
    //白色9點第3點
    const int DeeIndex(strResult.Find("第"));
    strResult = strResult.Right(strResult.GetLength() - DeeIndex); //第x點
//    DeeLength = strResult.Right(DeeIndex+2).GetLength();

    if ( strResult.Find("第") >= 0 )
    {
        if ( (strResult.FindOneOf("第") < strResult.FindOneOf("點")) &&
             (strResult.FindOneOf("點") >= 0) )
            return rMI_Dian;
        else
            return rMI_Normal;
    }
	else if (isNumber(strResult))
		return rMI_PureDigital;
    else
    {
        strResult.Empty();
        return rMI_NoMatch;
    }
}