コード例 #1
0
ファイル: Conversions.cpp プロジェクト: swax/Gnucleus
CString GetPercentage(DWORD dWhole, DWORD dPart)
{
	CString result = "0.00";

	if(dPart > dWhole)
		dPart = dWhole;

	if(dWhole)
	{
		result = DWrdtoStr(dPart * 10000 / dWhole);

		if(result.GetLength() > 2)
			result.Insert( result.GetLength() - 2, ".");
		else
		{
			switch(result.GetLength())
			{
			case 2:
				result.Insert(0, "0.");
				break;
			case 1:
				result.Insert(0, "0.0");
				break;
			default:
				result = "0.00";
				break;
			}
		}
	}

	return result + " %";
}
コード例 #2
0
ファイル: DirBrowns.cpp プロジェクト: hgl888/nashtest
//检查目录的合法性
BOOL CDirBrowns::CheckPath(CString &temp)
{	
	CString fPath;
	if(temp.Find(_T(":"))!=1) 
	{	fPath="c:";
		m_drvList.GetSelect(fPath);
		fPath+='\\';
		temp.Insert(0,fPath); }
	if(temp.Find('\\')!=2) temp.Insert(2,'\\');
	WIN32_FIND_DATA data;	   
	if(temp[temp.GetLength()-1]=='\\'&&
	   temp.GetLength()>3) temp.SetAt(temp.GetLength()-1,0);
	HANDLE handle=INVALID_HANDLE_VALUE;

	fPath=temp.Left(2);
	if(m_drvList.CheckDisk(fPath))
	{	if(temp.GetLength()>3)
		{
			handle=::FindFirstFile(temp,&data);
			::FindClose(handle);
			if(handle!=INVALID_HANDLE_VALUE&&
				(data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)==0)
				handle=INVALID_HANDLE_VALUE;
		}
	    else handle=0;
	}	
	if(handle==INVALID_HANDLE_VALUE) return FALSE;
	return TRUE;
}
コード例 #3
0
ファイル: main.cpp プロジェクト: ggonzalez/Man-In-Remote
CString byte2str(byte *bytes, int len)
{
	int 	pos = 0;
	CString ret;
	char 	pBuffer[100];

	for(int n = 0; n < len; n ++)
	{
		_itoa(bytes[n], pBuffer, 16);

		if(bytes[n] < 16)
		{
			ret.Insert(pos, "0");
			pos++;
			ret.Insert(pos, pBuffer);
			pos++;
		}
		else
		{
			ret.Insert(pos, pBuffer);
			pos+=2;
		}
	}

	ret.MakeUpper();
	return ret;
}
コード例 #4
0
//***************************************************************************************
int CBCGPXMLNode::WriteToBuffer (CString& strBuffer, int iOffset)
{
	if (m_lstChildren.IsEmpty () && m_pParent != NULL)
	{
		CString strTagValue;
		strTagValue.Format (_T("<%s>\"%s\"</%s>\n"), m_strName, m_strValue, m_strName);

		strBuffer.Insert (iOffset, strTagValue);
		return strTagValue.GetLength ();
	}

	int iOffsetOrig = iOffset;

	CString strTagStart;
	strTagStart.Format (_T("<%s>\n"), m_strName);

	strBuffer.Insert (iOffset, strTagStart);
	iOffset += strTagStart.GetLength ();

	for (POSITION pos = m_lstChildren.GetHeadPosition (); pos != NULL;)
	{
		CBCGPXMLNode* pNode = m_lstChildren.GetNext (pos);
		ASSERT_VALID (pNode);

		iOffset += pNode->WriteToBuffer (strBuffer, iOffset);
	}

	CString strTagEnd;
	strTagEnd.Format (_T("</%s>\n"), m_strName);

	strBuffer.Insert (iOffset, strTagEnd);
	iOffset += strTagEnd.GetLength ();

	return iOffset - iOffsetOrig;
}
コード例 #5
0
char * UnicodeToUTF_8(WCHAR *UniChar) // Unicode 转换成UTF-8
{
	char *buffer;
	CString strOne;
	CString strTwo;
	CString strThree;
	CString strFour;
	CString strAnd;
	buffer = new char[3];
	int hInt,lInt;
	hInt = (int)((*UniChar)/256);
	lInt = (*UniChar)%256;
	CString string ;
	string.Format("%x",hInt);
	strTwo = HexToBin(string.Right(1));
	string = string.Left(string.GetLength() - 1);
	strOne = HexToBin(string.Right(1));
	string.Format("%x",lInt);
	strFour = HexToBin(string.Right(1));
	string = string.Left(string.GetLength() -1);
	strThree = HexToBin(string.Right(1));
	strAnd = strOne +strTwo + strThree + strFour;
	strAnd.Insert(0,"1110");
	strAnd.Insert(8,"10");
	strAnd.Insert(16,"10");
	strOne = strAnd.Left(8);
	strAnd = strAnd.Right(16);
	strTwo = strAnd.Left(8);
	strThree = strAnd.Right(8);
	*buffer = (char)BinToInt(strOne);
	buffer[1] = (char)BinToInt(strTwo);
	buffer[2] = (char)BinToInt(strThree);
	return buffer;
}     
コード例 #6
0
ファイル: DlgDownloadGroup.cpp プロジェクト: nlstone/Shareaza
void CDownloadGroupDlg::OnCbnCloseupSchemas()
{
    // Get filters
    CList< CString > oList;
    for ( int nItem = 0 ; nItem < m_wndFilterList.GetCount() ; nItem++ )
    {
        CString strFilter;
        m_wndFilterList.GetLBText( nItem, strFilter );
        if ( oList.Find( strFilter ) == NULL )
            oList.AddTail( strFilter );
    }

    // Remove old schema filters (preserve custom ones)
    if ( CSchemaPtr pOldSchema = SchemaCache.Get( m_sOldSchemaURI ) )
    {
        for ( POSITION pos = pOldSchema->GetFilterIterator(); pos ; )
        {
            CString strFilter;
            BOOL bResult;
            pOldSchema->GetNextFilter( pos, strFilter, bResult );
            if ( bResult )
            {
                strFilter.Insert( 0, _T('.') );
                while ( POSITION pos = oList.Find( strFilter ) )
                    oList.RemoveAt( pos );
            }
        }
    }

    // Add new schema filters
    if ( CSchemaPtr pNewSchema = SchemaCache.Get( m_wndSchemas.GetSelectedURI() ) )
    {
        for ( POSITION pos = pNewSchema->GetFilterIterator(); pos ; )
        {
            CString strFilter;
            BOOL bResult;
            pNewSchema->GetNextFilter( pos, strFilter, bResult );
            if ( bResult )
            {
                strFilter.Insert( 0, _T('.') );
                oList.AddTail( strFilter );
            }
        }
    }

    // Refill interface filters list
    m_wndFilterList.ResetContent();
    for ( POSITION pos = oList.GetHeadPosition() ; pos ; )
        m_wndFilterList.AddString( oList.GetNext( pos ) );

    m_sOldSchemaURI = m_wndSchemas.GetSelectedURI();
}
コード例 #7
0
/**
 * Gets change directory info from previous lines, feature only 
 * for cmdl and compiler tab, all other tabs return sFile unchanged.
 *
 * @param           iLine: zero based line index from where to 
 *                  search cd [path] commands backward until
 *                  first line or cd <fullpath> or special cd $(prjdir) 
 *                  is found
 * @param           editCtrl: holds the text data
 * @param           sFile: in/out. gets updated to point to final path
 * @param  (HACK)   pMsgFrame: CMsgFrame, used to check if cmdl, compiler tab
 * @param  (HACK)   pDoc:      CMsgDoc, used to check if cmdl, compiler tab
 *                  may still be a (project) relative path on exit.
 * @see             -
*/
static void GetCDInfo(int iLine, CEdit& editCtrl, CString& sFile, CMsgFrame* pMsgFrame, CMsgDoc* pDoc)
{
    int          nLen;
    const TCHAR* pszDir;
    TCHAR        buffer[2*MAX_PATH];


    if(FC_StringIsAbsPath(sFile))
        return;
    if(iLine >= editCtrl.GetLineCount())
        return;

    //feature only for compiler tab (HACK):
    ASSERT (pMsgFrame != NULL);
    if (!pMsgFrame)
        return;
    int iIndex=-1;
    pMsgFrame->m_tabWnd.GetActiveTab(iIndex);
    if(!pDoc  || iIndex<0 || iIndex >= pDoc->m_arrMsgData.GetSize())
    {
        ASSERT (!"bad pDoc, iIndex");
        return;
    }
    MSG_VIEWER_TYPE msgTyp = pDoc->m_arrMsgData[iIndex].m_MsgViewerType;
    if(msgTyp != MSG_CmdLineMsgViewer && msgTyp != MSG_CompileMsgViewer)
        return;


    while(iLine>=0)
    {
        nLen = editCtrl.GetLine(iLine, buffer, FC_ARRAY_LEN(buffer)-10);
        iLine--;
        if(nLen<=0)
            continue;
        buffer[nLen] = 0;//<-needed ?
        FC_StringTrim(buffer);
        if((pszDir = IsLineCDInfo(buffer)) != NULL)
        {
            if(!*pszDir)
                break;//cd $(prjdir): don't prepend default prj dir as an abs path to sFile

            //all other rel or abs cd commands must be prepended:
            sFile.Insert(0, '\\');
            sFile.Insert(0, pszDir);
            //if is abs must stop here:
            if(FC_StringIsAbsPath(pszDir))
                break; 
        }
    }
}
コード例 #8
0
ファイル: IndexSearch.cpp プロジェクト: dblock/alkaline
void CIndex::AdjustMetas(CSearchObject& SearchObject) const {
    
    if (! SearchObject.m_SearchOptions.m_OptionMeta.GetSize())
        return;
    
    SearchObject.m_Adjustments.RemoveAll();
    
    int i, k;
    
    for (i=0;i<(int) SearchObject.m_SearchData.m_Words.GetSize();i++) {
        
        if (IsReservedKeyword(SearchObject.m_SearchData.m_Words[i])) 
            continue;
        
        // meta tag insertions
        
        if (SearchObject.m_SearchData.m_Words[i].Pos(':') == -1) {
            CString Word = SearchObject.m_SearchData.m_Words[i];
            
            // find the insertion point
            int MetaInsertPos = 0;
            while (MetaInsertPos < (int) Word.GetLength()) {
                if ((Word[MetaInsertPos] == '+') ||
                    (Word[MetaInsertPos] == '-') ||
					(Word[MetaInsertPos] == '\"')) {
						MetaInsertPos++;
						continue;				
					}
                break;
            }
            
            for (k = 0; k < (int) SearchObject.m_SearchOptions.m_OptionMeta.GetSize(); k++) {            
                if (! k) {
                    SearchObject.m_SearchData.m_Words[i].Insert(MetaInsertPos, ':');
                    SearchObject.m_SearchData.m_Words[i].Insert(MetaInsertPos, SearchObject.m_SearchOptions.m_OptionMeta[k]);
                } else {
                    CString WordAdded = Word;
                    WordAdded.Insert(MetaInsertPos, ':');
                    WordAdded.Insert(MetaInsertPos, SearchObject.m_SearchOptions.m_OptionMeta[k]);
                    SearchObject.m_Adjustments += WordAdded;
                }
            }
        }
    }

    SearchObject.m_SearchData.m_Words += SearchObject.m_Adjustments;
    SearchObject.m_Adjustments.RemoveAll();
}
コード例 #9
0
ファイル: visualmsdoc.cpp プロジェクト: artemeliy/inf4715
static int InsertTabs(CString &str, int numTabs, const TCHAR* indent, bool& bracketed)
{
	CString tabs = indent ? indent : _T("");
	for(int i = 0; i < numTabs; i++)
		tabs += _T("\t");

	str.TrimRight();
	str = tabs + str;
	bool sol = true; int line = 0;
	bracketed = false;
	for (int i = 0; i < str.GetLength(); i++)
	{
		if (str[i] == _T('\n') || str[i] == _T('\r'))
		{
			while (i < str.GetLength()-1 && str[++i] == _T('\n'));
			if (i < str.GetLength())
			{
				str.Insert(i, tabs);
				i += tabs.GetLength();
			}
			sol = true;
			continue;
		}
		if (str[i] == _T('(') && sol)
			bracketed = true;
		if (!_istspace(str[i]) && sol)
			line++, sol = false;
	}
	return line;
}
コード例 #10
0
// This function tries to execute a Java program (parameter 1) using 
// the supplied call (parameter 2). The first parameter ("the executable") 
// is needed for internal error management (i.e. did the Java call fail or 
// was the executable not found?). The function checks whether Java is 
// installed on the user's machine; if Java is installed, the function 
// determines if the desired program exists (thus we need parameter 1); 
// if the program exists, this function tries to execute the program 
// within a shell window
void ShellExecuteJava(const CString &_javaProgram, const CString &_javaProgramCompleteCall, const CString &_path) {

	CString javaProgram = _javaProgram;
	CString javaProgramCompleteCall = _javaProgramCompleteCall;

	// check if Java is installed
	if(reinterpret_cast<int>(ShellExecute(NULL, NULL, "java", NULL, NULL, SW_HIDE)) <= 32) {
		CString message;
		message.LoadStringA(IDS_STRING_JAVA_JRE_NOT_INSTALLED);
		AfxMessageBox(message, MB_ICONINFORMATION);
		return;
	}
	// check if Java program is there
	javaProgram.Insert(0, _path);
	struct stat javaProgramFileInformation;
	if(stat(javaProgram.GetBuffer(), &javaProgramFileInformation) != 0) {
		CString message;
		message.Format(IDS_STRING_JAVA_PROGRAM_NOT_FOUND, javaProgram);
		AfxMessageBox(message, MB_ICONINFORMATION);
		return;
	}
	// try to execute the Java progam
	if(reinterpret_cast<int>(ShellExecute(NULL, NULL, "java", javaProgramCompleteCall, _path, SW_HIDE)) <= 32) {
		CString message;
		message.LoadStringA(IDS_STRING_JAVA_PROGRAM_EXECUTION_FAILED);
		AfxMessageBox(message, MB_ICONSTOP);
		return;
	}	
}
コード例 #11
0
ファイル: WndDialog.cpp プロジェクト: iceberry/flyffsf
void CWndDialog::Say( LPCTSTR lpszString, DWORD dwQuest )
{
 	QuestProp* pQuestProp = prj.m_aPropQuest.GetAt( dwQuest );
 	CString string = "  ";
	if( dwQuest )
	{
		string = "#b#cff5050f0";
		string += pQuestProp->m_szTitle;
		string += "#nb#nc\n";
		string += "  ";
		string += lpszString;
	}
	else
		string += lpszString;

	int nLength = string.GetLength();//_tcslen( szString );
	int i,j; for( i = 0, j = 0; i < nLength; i++ )
	{
		if( string[ i ] == '\\' && string[ i + 1 ] == 'n' )
		{
			// 중간의 두개의 코드를 \n와 ' '로 대체.
			string.SetAt( i, '\n' );
			string.SetAt( i + 1, ' ' );
			// 그리고 스페이스 한개 삽입.
			string.Insert( i + 1, " " );
		}
	}
	m_dwQuest = dwQuest;
	ParsingString( string );
	EndSay();
}
コード例 #12
0
bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind)
{
	CString origRef;
	pComboBox->GetLBText(pComboBox->GetCurSel(), origRef);
	CString resultRef = PickRef(false,origRef,pickRef_Kind);
	if(resultRef.IsEmpty())
		return false;
	if(wcsncmp(resultRef,L"refs/",5)==0)
		resultRef = resultRef.Mid(5);
//	if(wcsncmp(resultRef,L"heads/",6)==0)
//		resultRef = resultRef.Mid(6);

	//Find closest match of choice in combobox
	int ixFound = -1;
	int matchLength = 0;
	CString comboRefName;
	for(int i = 0; i < pComboBox->GetCount(); ++i)
	{
		pComboBox->GetLBText(i, comboRefName);
		if(comboRefName.Find(L'/') < 0 && !comboRefName.IsEmpty())
			comboRefName.Insert(0,L"heads/"); // If combo contains single level ref name, it is usualy from 'heads/'
		if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName)
		{
			matchLength = comboRefName.GetLength();
			ixFound = i;
		}
	}
	if(ixFound >= 0)
		pComboBox->SetCurSel(ixFound);
	else
		ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog)

	return true;
}
コード例 #13
0
ファイル: CreatReport.cpp プロジェクト: wyrover/GDES
//处理精度
static void DealTolrance(const CString& data,CString& tolData)
{
	if(data.IsEmpty()) return;

	//小数点前面的0补全,并且除掉左右多余的0
	if (-1 == data.Find(_T(".")))
	{
		tolData = data;
		return;
	}
	CString strValue;
	strValue.Format(_T("%.2f"),_tstof(data));
	tolData = strValue;
	tolData.Replace(_T("0"),_T(" "));	//替换0为空格
	tolData.Trim();	//裁剪
	tolData.Replace(_T(" "),_T("0"));
	if(tolData[0] == _T('.')) tolData.Insert(0,_T("0"));
	int lenth = tolData.GetLength();
	if(0 >= lenth)
	{
		return;
	}
	if(tolData[lenth-1] == _T('.'))
	{
		tolData.Replace(_T("."),_T(" "));
		tolData.Trim();	//裁剪
	}
}
コード例 #14
0
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);
}
コード例 #15
0
ファイル: ColorRichEditView.cpp プロジェクト: deNULL/seman
void CColorRichEditView::SetAccentByIndex(int ind)
{
	CRichEditCtrl& re = GetRichEditCtrl();
	if( ind>=re.GetTextLength()-1 || ind<0 ) 
		return;
	CString Paradigm = GetText();
	int lineInd = re.LineIndex();
	int line_no = re.LineFromChar(lineInd);
	ind += line_no; // delete '\r'
	if(!is_lower_vowel(Paradigm[ind], m_morphWizard.m_Language) )
		return;
	int wordStart = ind;
	{
		while (wordStart > 0 && !isspace((BYTE) Paradigm[wordStart]))
			wordStart--;
	};
	DWORD wordEnd = ind;

	while (wordEnd < Paradigm.GetLength() && !isspace((BYTE)Paradigm.GetAt(wordEnd) ))
		wordEnd++;
	int accOld = Paradigm.Find("'",wordStart);
	if( accOld>=0  && accOld < wordEnd) 
	{
		if( accOld<ind ) --ind;
		Paradigm.Delete(accOld);
	}
	Paradigm.Insert(ind+1,"'");
	SetText(Paradigm);
	
}
コード例 #16
0
ファイル: TEditCtrlWnd.CPP プロジェクト: kjkpoi/Stock_API
BOOL CTEditCtrlWnd::TimeFormat(CString str)
{
	if(!m_bTimeType)
		return FALSE;		
	
	CString strTime;
	if(m_pEditCtrl != NULL)
		GetWindowText(strTime);
	
	if(strTime.GetLength() == 6)
	{
		strTime.Insert(2, _T(':'));
		strTime.Insert(5, _T(':'));

		m_pEditCtrl->SetWindowText((LPCTSTR)strTime);
		m_pEditCtrl->SetTimeType(TRUE);
	}
	else
	{
		CString strErrorMsg;
		strErrorMsg.Format("시분초 각 두자리씩 숫자로만 표시해주십시요.");
		MessageBox(strErrorMsg, MB_OK);
		SetFocus();
		return FALSE;						
	}

	return TRUE;
}
コード例 #17
0
CString GetCardIdFromCenter(CString netId)
{
	CString strTmp = netId;
	//在账号前段插入0
	if (strTmp.GetLength() < 10)
	{
		strTmp.Insert(0, CString(_T("0000000000")).Left(10 - strTmp.GetLength()));
	}

	BOOL bRet = FALSE;

	CIDCheckCardMethod checkCard;
	checkCard.SetSerialNum(strTmp);

	::CoInitialize(NULL);
	theApp.GetCurCashier()->DoCheckCard(checkCard);
	::CoUninitialize();

	if (checkCard.GetStatusCode() == 0)
	{
		if (checkCard.GetMemberId() != 0) //已经开过的卡,充值退卡
		{
			return _T("");
		}
		else //新卡注册
		{
			return checkCard.GetCardIdAsString();
		}
	}
	else
	{
		return _T("");
	}

}
コード例 #18
0
ファイル: Loc.cpp プロジェクト: 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;
}
コード例 #19
0
ファイル: FileMisc.cpp プロジェクト: noindom99/repositorium
bool FileMisc::LoadFile(const TCHAR* szPathname, CString& sText)
{
	CStdioFile file;

	if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite))
	{
		if (file.GetLength())
		{
			// init size
			CString sTemp(_T('\0'), (int)file.GetLength());
			sText = sTemp;

			CString sLine;
			int nPos = 0;

			while (file.ReadString(sLine))
			{
				sText.Insert(nPos, sLine);
				nPos += sLine.GetLength();
			}
		}

		return true;
	}

	return false;
}
コード例 #20
0
CString CMyPath::TransferSourcePath( LPCTSTR strSource, LPCTSTR strDest, LPCTSTR strFileName )
{
	CString strPath = strFileName;
	strPath.Delete(0, lstrlen(strSource));
	strPath.Insert(0, strDest);

	return strPath;
}
コード例 #21
0
ファイル: IrcWnd.cpp プロジェクト: brolee/EMule-GIFC
void CIrcWnd::OnBnClickedBold()
{
	CString sAddAttribute;
	int	iSelStart;
	int	iSelEnd;

	m_wndInput.GetSel(iSelStart, iSelEnd);//get selection area
	m_wndInput.GetWindowText(sAddAttribute);//get the whole line
	if(iSelEnd > iSelStart)
		sAddAttribute.Insert(iSelEnd, _T('\x02'));//if a selection add end tag
	sAddAttribute.Insert(iSelStart, _T('\x02'));//add start tag
	iSelStart++;//increment start position
	iSelEnd++;//increment end position
	m_wndInput.SetWindowText(sAddAttribute);//write new line to edit control
	m_wndInput.SetSel(iSelStart, iSelEnd);//update selection info
	m_wndInput.SetFocus();//set focus (from button) to edit control
}
コード例 #22
0
/******************************************************************************
Function Name  :  strCopyBSTRToCString
Input(s)       :  CComVariant& varSrc
Output         :  CString
Functionality  :  Copies BSTR to CString
Member of      :  -
Friend of      :  -
Author(s)      :  Arunkumar K
Date Created   :  20/07/2011
Modifications  :
Codetag        :
******************************************************************************/
CString strCopyBSTRToCString(CComVariant& varSrc)
{
    CString strDest ;
    char tChar = NULL;
    _bstr_t bstrNodeValue(varSrc.bstrVal);
    ULONG ulLen = bstrNodeValue.length();

    for (unsigned int i = 0; i< ulLen*2; i+=2)
    {
        tChar = (char)*(varSrc.pcVal+i);
        strDest.Insert(i/2, tChar);
    }

    tChar = NULL;
    strDest.Insert(ulLen, tChar);
    return strDest;
}
コード例 #23
0
ファイル: misc.cpp プロジェクト: ratever930/freedownload
CString fsBytesToStr (UINT64 uBytes, BOOL bAdd_bytes_String)
{
	CString strBytes; 
	if (bAdd_bytes_String)
	{
		strBytes = " ";
		strBytes += LS (L_B);
	}
	CString str;
	UINT u;

	do
	{
		 if (uBytes > 1000)
			 u = UINT (uBytes % 1000);
		 else
			 u = 0;

		if (u)
		{
			str.Format (",%d", u);
			if (str.GetLength () == 2)
				str.Insert (1, "00");
			else if (str.GetLength () == 3)
				str.Insert (1, "0");
		}
		else
		{
			if (uBytes < 1000)
				str.Format ("%d", (UINT)uBytes);
			else
			{
				str = ",000";
			}
		}

		uBytes /= 1000;

		strBytes.Insert (0, str);
	}
	while (uBytes);

	return strBytes;
}
コード例 #24
0
//转换字符串
void MakeString(CString &strNum,SCORE lNumber)
{
	CString strTempNum;
	strTempNum.Format(_T("%I64d"), (lNumber>0?lNumber:-lNumber));

	int nLength = strTempNum.GetLength();
	for (int i = 0; i < int((nLength-1)/3); i++)
		strTempNum.Insert(nLength - 3*(i+1), _T(","));
	strNum.Format(_T("%s%s"), (lNumber<0?_T("-"):_T("")), strTempNum);
}
コード例 #25
0
ファイル: helper.cpp プロジェクト: MarkYangUp/HP-Socket
void LogMsg(const CString& msg)
{
	if(!g_pInfoList || !g_pInfoList->GetSafeHwnd())
		return;

	g_pInfoList->SetRedraw(FALSE);

	int iCurIndex	= g_pInfoList->GetCurSel();

	BOOL bFirst		= TRUE;
	int iStart		= 0;
	int iAdd		= 0;

	while(true)
	{
		CString item = msg.Tokenize(_T("\r\n"), iStart);

		if(iStart == -1)
			break;

		if(bFirst)
			bFirst = FALSE;
		else
			item.Insert(0, _T("      | "));

		g_pInfoList->AddString(item);
		++iAdd;
	}

	int iCount		= g_pInfoList->GetCount();
	BOOL bCurLast	= (iCurIndex == LB_ERR || iCurIndex + iAdd == iCount - 1);

	int iDec = 0;
	while(g_pInfoList->GetCount() > MAX_LOG_RECORD_LENGTH)
	{
		g_pInfoList->DeleteString(0);
		++iDec;
	}

	if(bCurLast)
	{
		iCurIndex = iCount - iDec - 1;
		g_pInfoList->SetCurSel(iCurIndex);
	}
	else if(iCurIndex < iDec)
	{
		iCurIndex = 0;
		g_pInfoList->SetCurSel(iCurIndex);
	}
	else
		iCurIndex = g_pInfoList->GetCurSel();

	g_pInfoList->SetAnchorIndex(iCurIndex);
	g_pInfoList->SetRedraw(TRUE);
}
コード例 #26
0
	int XMLWriter::WriteValue(CString name, CString value)
	{
		if (!has_params.empty()) {
			bool param = has_params.back();
			if (!param) {
				has_params.pop_back();
				has_params.push_back(true);
			}
		}

		#pragma region Escape Special Characters
		// NOTE: http://www.w3.org/TR/html4/sgml/entities.html#h-24.4.1
		for (int i=value.GetLength()-1; i>=0; i--) {
			CString replacement;
			switch(value[i]) {
				case _T('&'):
					replacement = _T("&amp;");
					break;
				case _T('<'):
					replacement = _T("&lt;");
					break;
				case _T('>'):
					replacement = _T("&gt;");
					break;
			}
			if(replacement.IsEmpty())
				continue;
			value.Delete(i);
			value.Insert(i, replacement);
		}
		#pragma endregion

		// escape quotes
		for (int i=value.GetLength()-1; i>=0; i--) {
			if (value[i] == L'\"') {
				value.Insert(i, _T("\\"));
			}
		}

		ret += _T(" ")+name+_T("=\"") + value + _T("\"");
		return 0;
	}
コード例 #27
0
// overloaded method: double (with extra parameter for amount of decimal places)
CString createStringNumberWithDigitGrouping(const double &_number, const unsigned int &_numberOfDecimalPlaces) {
	CString stringNumber;
	// create format string (for decimal places)
	CString stringFormat; stringFormat.Format("%d", _numberOfDecimalPlaces);
	stringFormat.Insert(0, "%.");
	stringFormat.Append("f");
	// convert number to string
	stringNumber.Format(stringFormat, _number);
	// add digit grouping and return result
	return createStringNumberWithDigitGrouping(stringNumber);
}
コード例 #28
0
void Filename_AccountForLOD(CString &string, int iLODLevel)
{
	if (iLODLevel)
	{
		int loc = string.ReverseFind('.');
		if (loc>0)
		{
			string.Insert( loc, va("_%d",iLODLevel));
		}		
	}	
}
コード例 #29
0
ファイル: IrcWnd.cpp プロジェクト: brolee/EMule-GIFC
void CIrcWnd::OnBnClickedReset()
{
	CString sAddAttribute;
	int iSelStart;
	int	iSelEnd;

	m_wndInput.GetSel(iSelStart, iSelEnd);//get selection area
	if(!iSelStart)
		return;//reset is not a first character
	m_wndInput.GetWindowText(sAddAttribute);//get the whole line
	//Note the 'else' below! this tag resets all atttribute so only one tag needed at current position or end of selection
	if(iSelEnd > iSelStart)
		sAddAttribute.Insert(iSelEnd, _T('\x0f'));//if a selection add end tag
	else
		sAddAttribute.Insert(iSelStart, _T('\x0f'));//add start tag
	iSelStart++;//increment start position
	iSelEnd++;//increment end position
	m_wndInput.SetWindowText(sAddAttribute);//write new line to edit control
	m_wndInput.SetSel(iSelStart, iSelEnd);//update selection info
	m_wndInput.SetFocus();//set focus (from button) to edit control
}
コード例 #30
-1
bool CFileBrowserListCtrl::RenameFile(HWND hWnd, LPCTSTR OldName, LPCTSTR NewName, FILEOP_FLAGS Flags)
{
	// pFrom/pTo can contain multiple names and must be double null-terminated
	CString	sFrom = OldName;
	CString	sTo = NewName;
	sFrom.Insert(sFrom.GetLength(), TCHAR(0));	// add extra terminator
	sTo.Insert(sTo.GetLength(), TCHAR(0));	// add extra terminator
	SHFILEOPSTRUCT	op;
	ZeroMemory(&op, sizeof(op));
	op.pFrom = sFrom;
	op.pTo = sTo;
	op.hwnd = hWnd;
	op.wFunc = FO_RENAME;
	op.fFlags = Flags;
	if (SHFileOperation(&op))	// non-zero result means failure
		return(FALSE);
	// if the rename causes a confirmation dialog and the user cancels, 
	// SHFileOperation returns success though the file was NOT renamed
	return(PathFileExists(NewName) != 0);	// verify that rename succeeded
}