本文整理汇总了C++中CString::Insert方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Insert方法的具体用法?C++ CString::Insert怎么用?C++ CString::Insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPercentage
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: CheckPath
//检查目录的合法性
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: byte2str
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: WriteToBuffer
//***************************************************************************************
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: OnCbnCloseupSchemas
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();
}
示例6: GetCDInfo
/**
* 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;
}
}
}
示例7: AdjustMetas
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();
}
示例8: InsertTabs
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;
}
示例9: ShellExecuteJava
// 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;
}
}
示例10: Say
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();
}
示例11: PickRefForCombo
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;
}
示例12: DealTolrance
//处理精度
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(); //裁剪
}
}
示例13: WriteProp
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);
}
示例14: SetAccentByIndex
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);
}
示例15: TimeFormat
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;
}