本文整理汇总了C++中CString::Replace方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Replace方法的具体用法?C++ CString::Replace怎么用?C++ CString::Replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteKeywordDataToFile
void KeywordManager::WriteKeywordDataToFile()
{
CFile keyword_data_file;
BOOL ret=MakeSureDirectoryPathExists("Keyword Files\\");
for(UINT i=0; i<v_all_project_keywords.size(); i++)
{
BOOL open_write = FALSE;
char filename[256+1];
strcpy(filename, "Keyword Files\\");
CString project = v_all_project_keywords[i].m_project_name.c_str();
project.Replace('\\','_'); // replace the backslash with _
project.Replace('\'', '_'); // replace the single quote "'" with _
project.Replace(' ', '_');
project.Replace('-', '_');
project.Replace('&', '_');
project.Replace('!', '_');
project.Replace('$', '_');
project.Replace('@', '_');
project.Replace('%', '_');
project.Replace('(', '_');
project.Replace(')', '_');
project.Replace('+', '_');
project.Replace('~', '_');
project.Replace('*', '_');
project.Replace('.', '_');
project.Replace(',', '_');
project.Replace('?', '_');
project.Replace(':', '_');
project.Replace(';', '_');
project.Replace('"', '_');
project.Replace('/', '_');
strcat(filename, project);
strcat(filename, ".kwd");
/*
CFile test;
bool existed = test.Open(filename,CFile::modeRead);
if(existed)
{
MessageBox(NULL,filename,"Bingo",MB_OK);
test.Close();
}
*/
open_write = keyword_data_file.Open(filename,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone);
if(open_write==TRUE)
{
int buf_len = v_all_project_keywords[i].GetBufferLength();
char *buf = new char[buf_len];
v_all_project_keywords[i].WriteToBuffer(buf);
keyword_data_file.Write(buf, buf_len);
delete [] buf;
keyword_data_file.Close();
}
}
}
示例2: GetCurrentFileCommentString
CString CDlgMainTabRss::GetCurrentFileCommentString()
{
if (!m_pwndRssFeed || !::IsWindow(m_pwndRssFeed->m_hWnd))
{
return CString(_T(""));
}
POSITION Pos = NULL;
if (m_pwndRssFeed->m_ListShowMode == LISTSTYLE_ICO)
{
Pos = m_pwndRssFeed->m_listIcoFeedItem.GetFirstSelectedItemPosition();
}
else if (m_pwndRssFeed->m_ListShowMode == LISTSTYLE_ITEM)
{
Pos = m_pwndRssFeed->m_listFeedItem.GetFirstSelectedItemPosition();
}
else if(m_pwndRssFeed->m_ListShowMode == LISTSTYLE_SINGLE)
{
Pos = m_pwndRssFeed->m_listSingleFeedItem.GetFirstSelectedItemPosition();
}
if (!Pos)
{
return CString(_T(""));
}
int nIndex;
CRssFeed::Item* pItem;
if (m_pwndRssFeed->m_ListShowMode == LISTSTYLE_ICO)
{//ICO模式没有item
nIndex = m_pwndRssFeed->m_listIcoFeedItem.GetNextSelectedItem(Pos);
pItem = NULL;
}
else if (m_pwndRssFeed->m_ListShowMode == LISTSTYLE_ITEM)
{
nIndex = m_pwndRssFeed->m_listFeedItem.GetNextSelectedItem(Pos);
pItem = m_pwndRssFeed->m_listFeedItem.GetFeedItem(nIndex);
}
else if(m_pwndRssFeed->m_ListShowMode == LISTSTYLE_SINGLE)
{
nIndex = m_pwndRssFeed->m_listSingleFeedItem.GetNextSelectedItem(Pos);
pItem = m_pwndRssFeed->m_listSingleFeedItem.GetFeedItem(nIndex);
}
if (pItem && pItem->GetPartFile())
{
CPartFile * pPartFile = pItem->GetPartFile();
CString strFileEd2k = CreateED2kLink(pPartFile, false);
if( strFileEd2k.IsEmpty() )
{
return CString(_T(""));
}
bool bFileisFinished = true;
if( pPartFile->IsKindOf(RUNTIME_CLASS(CPartFile)) )
{
if( ((CPartFile*)pPartFile)->GetStatus()!=PS_COMPLETE )
bFileisFinished = false;
}
CString strCommentUrl = bFileisFinished ? thePrefs.m_strFinishedFileCommentUrl : thePrefs.m_strPartFileCommentUrl;
strCommentUrl.Replace(_T("[ed2k]"),strFileEd2k);
strCommentUrl.Replace(_T("|"), _T("%7C"));
CString sVersion;
sVersion.Format(_T("&v=%u"),VC_VERSION_BUILD);
strCommentUrl += sVersion;
return strCommentUrl;
}
else if (pItem)
{
CString strED2KUrl = pItem->m_strEnclosure;
if( strED2KUrl.IsEmpty() || strED2KUrl.Left(7).CompareNoCase(_T("ed2k://")))
{
return CString(_T(""));
}
CString strCommentUrl = thePrefs.m_strPartFileCommentUrl;
strCommentUrl.Replace(_T("[ed2k]"),strED2KUrl);
strCommentUrl.Replace(_T("|"), _T("%7C"));
CString sVersion;
sVersion.Format(_T("&v=%u"),VC_VERSION_BUILD);
strCommentUrl += sVersion;
return strCommentUrl;
}
else
{
CRssFeed* pFeed;
if (m_pwndRssFeed->m_ListShowMode == LISTSTYLE_ITEM)
{
pFeed = m_pwndRssFeed->m_listFeedItem.GetFeed(nIndex);
}
else if(m_pwndRssFeed->m_ListShowMode == LISTSTYLE_SINGLE)
{
pFeed = m_pwndRssFeed->m_listSingleFeedItem.GetFeed(nIndex);
}
//.........这里部分代码省略.........
示例3: OnOK
//.........这里部分代码省略.........
CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK2)),
L"TortoiseSVN",
0,
TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK3)));
taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK4)));
taskdlg.SetCommonButtons(TDCBF_CANCEL_BUTTON);
taskdlg.SetExpansionArea(CString(MAKEINTRESOURCE(IDS_WARN_NOVALIDPATH_TASK5)));
taskdlg.SetDefaultCommandControl(2);
taskdlg.SetMainIcon(TD_WARNING_ICON);
if (taskdlg.DoModal(m_hWnd) != 1)
return;
}
CStringUtils::WriteAsciiStringToClipboard(m_URL);
// now let the bugtraq plugin check the commit message
CComPtr<IBugTraqProvider2> pProvider2 = NULL;
if (m_BugTraqProvider)
{
HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
if (SUCCEEDED(hr))
{
ATL::CComBSTR temp;
ATL::CComBSTR sourceURL;
sourceURL.Attach(m_wcURL.AllocSysString());
ATL::CComBSTR parameters;
parameters.Attach(m_bugtraq_association.GetParameters().AllocSysString());
ATL::CComBSTR targetURL;
targetURL.Attach(m_URL.AllocSysString());
ATL::CComBSTR commitMessage;
commitMessage.Attach(m_sLogMessage.AllocSysString());
CBstrSafeVector pathList(1);
pathList.PutElement(0, m_path.GetSVNPathString());
hr = pProvider2->CheckCommit(GetSafeHwnd(), parameters, sourceURL, targetURL, pathList, commitMessage, &temp);
if (FAILED(hr))
{
OnComError(hr);
}
else
{
CString sError = temp == 0 ? L"" : temp;
if (!sError.IsEmpty())
{
CAppUtils::ReportFailedHook(m_hWnd, sError);
return;
}
}
}
}
CTSVNPathList checkedItems;
checkedItems.AddPath(m_path);
DWORD exitcode = 0;
CString error;
CHooks::Instance().SetProjectProperties(m_path, m_ProjectProperties);
if (CHooks::Instance().CheckCommit(m_hWnd, checkedItems, m_sLogMessage, exitcode, error))
{
if (exitcode)
{
CString sErrorMsg;
sErrorMsg.Format(IDS_HOOK_ERRORMSG, (LPCWSTR)error);
CTaskDialog taskdlg(sErrorMsg,
CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK2)),
L"TortoiseSVN",
0,
TDF_ENABLE_HYPERLINKS | TDF_USE_COMMAND_LINKS | TDF_ALLOW_DIALOG_CANCELLATION | TDF_POSITION_RELATIVE_TO_WINDOW | TDF_SIZE_TO_CONTENT);
taskdlg.AddCommandControl(1, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK3)));
taskdlg.AddCommandControl(2, CString(MAKEINTRESOURCE(IDS_HOOKFAILED_TASK4)));
taskdlg.SetDefaultCommandControl(1);
taskdlg.SetMainIcon(TD_ERROR_ICON);
bool retry = (taskdlg.DoModal(GetSafeHwnd()) == 1);
if (retry)
return;
}
}
if (!m_sLogMessage.IsEmpty())
{
m_History.AddEntry(m_sLogMessage);
m_History.Save();
}
m_sBugID.Trim();
if (!m_sBugID.IsEmpty())
{
m_sBugID.Replace(L", ", L",");
m_sBugID.Replace(L" ,", L",");
CString sBugID = m_ProjectProperties.sMessage;
sBugID.Replace(L"%BUGID%", m_sBugID);
if (m_ProjectProperties.bAppend)
m_sLogMessage += L"\n" + sBugID + L"\n";
else
m_sLogMessage = sBugID + L"\n" + m_sLogMessage;
UpdateData(FALSE);
}
CResizableStandAloneDialog::OnOK();
}
示例4: CreateMenus
void CAddCADFrameMenu::CreateMenus()
{
CMDIFrameWnd * pMainFrame = acedGetAcadFrame();
pMainFrame->LockWindowUpdate();
//得到菜单栏上面的最后一个菜单
CString sName;
if(!GetLastMenuFromMenubar(sName))
return;
sName.Replace(_T("&"),_T(""));//debug
IAcadMenuGroup *mnuGrp = NULL;
if (!GetAcadMenuGroup(&mnuGrp,sName))
return ;
//得到所有菜单组
IAcadPopupMenus *mnus = NULL;
IAcadPopupMenu *mnu = NULL;
IAcadPopupMenuItem *mnuitem = NULL;
HRESULT hr = S_OK;
hr = mnuGrp->get_Menus(&mnus);
long cnt = 0l;
hr = mnus->get_Count(&cnt);
int i = 0;
int j = 0;
int k = 0;
VARIANT index;
VariantInit(&index);
V_VT(&index) = VT_I4;
CArray<IAcadPopupMenu*, IAcadPopupMenu*> MnuAdrs;
long lIndex=0;
for (i = 0; i < m_menuCount; i++)
{
CString tmpMenu=m_TopMenuNames[i];
tmpMenu.Replace(_T("&"),_T(""));
if(IsMenuExist(mnu,lIndex,tmpMenu,mnus))//处理二次加载
{
V_I4(&index) = lIndex;
}
else
{
mnus->Add(m_TopMenuNames[i].AllocSysString(), &mnu);
V_I4(&index) = cnt++;
}
MnuAdrs.Add(mnu);
mnu->InsertInMenuBar(index);
}
IAcadPopupMenu *MenuItem = NULL;
int subMenuNum = 0;
CCADMenuArray* Menus;
TCHAR szSubMenu[64];
TCHAR szSubMenuMacro[64];
CString MenusName;
CString Menusorder;
for (j = 0; j < m_menuCount; j++) {
Menus = m_menus.GetAt(j);
subMenuNum = Menus->GetSize();
for (k = 0; k < subMenuNum; k++) {
mnu = MnuAdrs.GetAt(j);
if (!_tcscmp(_T("--"), Menus->GetAt(k)->name)) {
V_I4(&index) = k;
mnu->AddSeparator(index, &mnuitem);
}
else {
V_I4(&index) = k;
MenusName = Menus->GetAt(k)->name;
Menusorder = Menus->GetAt(k)->macro;
if (_tcscspn(Menus->GetAt(k)->name, _T("*")) < (size_t)MenusName.GetLength()){
MenusName.TrimLeft('*');
hr = mnu->AddSubMenu(index, MenusName.AllocSysString(), &MenuItem);
}
else if (_tcscspn(Menus->GetAt(k)->name, _T("$")) < (size_t)MenusName.GetLength() ){
MenusName.TrimLeft('$');
if(MenusName.Compare(_T("--"))==0)//添加子菜单的分隔符
{
hr = MenuItem->AddSeparator(index, &mnuitem);
}
else
{
hr = MenuItem->AddMenuItem(index, MenusName.AllocSysString(), Menusorder.AllocSysString(), &mnuitem);
}
}
else {
hr = mnu->AddMenuItem(index, MenusName.AllocSysString(), Menusorder.AllocSysString(), &mnuitem);
}
}
}
}
for (i=0; i<MnuAdrs.GetSize(); i++)
{
MnuAdrs[i]->Release();
}
mnuitem->Release();
mnus->Release();
//.........这里部分代码省略.........
示例5: OnInitDialog
BOOL CSwitchDlg::OnInitDialog()
{
CResizableStandAloneDialog::OnInitDialog();
ExtendFrameIntoClientArea(IDC_REVGROUP);
m_aeroControls.SubclassOkCancelHelp(this);
CTSVNPath svnPath(m_path);
SetDlgItemText(IDC_SWITCHPATH, m_path);
m_bFolder = svnPath.IsDirectory();
SVN svn;
CString sUUID;
m_repoRoot = svn.GetRepositoryRootAndUUID(svnPath, true, sUUID);
m_repoRoot.TrimRight('/');
CString url = svn.GetURLFromPath(svnPath);
m_URLCombo.LoadHistory(_T("Software\\TortoiseSVN\\History\\repoPaths\\")+sUUID, _T("url"));
m_URLCombo.SetCurSel(0);
if (!url.IsEmpty())
{
CString relPath = url.Mid(m_repoRoot.GetLength());
CTSVNPath r = CTSVNPath(relPath);
relPath = r.GetUIPathString();
relPath.Replace('\\', '/');
m_URLCombo.AddString(relPath, 0);
m_URLCombo.SelectString(-1, relPath);
m_URL = url;
SetDlgItemText(IDC_DESTURL, CPathUtils::CombineUrls(m_repoRoot, relPath));
}
if (m_sTitle.IsEmpty())
GetWindowText(m_sTitle);
SetWindowText(m_sTitle);
if (m_sLabel.IsEmpty())
GetDlgItemText(IDC_URLLABEL, m_sLabel);
SetDlgItemText(IDC_URLLABEL, m_sLabel);
// set head revision as default revision
SetRevision(SVNRev::REV_HEAD);
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_WORKING)));
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_INFINITE)));
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_IMMEDIATE)));
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_FILES)));
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EMPTY)));
m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EXCLUDE)));
m_depthCombo.SetCurSel(0);
RECT rect;
GetWindowRect(&rect);
m_height = rect.bottom - rect.top;
AddAnchor(IDC_SWITCHLABEL, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_SWITCHPATH, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_URLLABEL, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_BROWSE, TOP_RIGHT);
AddAnchor(IDC_DESTLABEL, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_DESTURL, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_REVGROUP, TOP_LEFT);
AddAnchor(IDC_REVISION_HEAD, TOP_LEFT);
AddAnchor(IDC_REVISION_N, TOP_LEFT);
AddAnchor(IDC_REVISION_NUM, TOP_LEFT);
AddAnchor(IDC_LOG, TOP_LEFT);
AddAnchor(IDC_GROUPMIDDLE, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_DEPTH, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_NOEXTERNALS, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDOK, BOTTOM_RIGHT);
AddAnchor(IDCANCEL, BOTTOM_RIGHT);
AddAnchor(IDHELP, BOTTOM_RIGHT);
if ((m_pParentWnd==NULL)&&(hWndExplorer))
CenterWindow(CWnd::FromHandle(hWndExplorer));
EnableSaveRestore(_T("SwitchDlg"));
return TRUE;
}
示例6: specIn
LRESULT CClientListCtrl::OnP4ClientSpec(WPARAM wParam, LPARAM lParam)
{
m_PrevNbrCli = m_UpdateState == LIST_CLEAR ? -1 : GetItemCount();
m_saveclientnew = m_ClientNew; // save name of freshly created client
CCmd_EditSpec *pCmd = (CCmd_EditSpec *) wParam;
if (pCmd->GetUseLocalDefTmplate())
{
CString specIn(pCmd->GetSpecIn());
int i;
if ((i = specIn.Find(_T("\n\nClient:\t"))) != -1)
{
CString tmplate = GET_P4REGPTR()->GetLocalCliTemplate();
tmplate.Replace(LOCALDEFTEMPLATE, pCmd->GetItemName());
pCmd->SetSpecIn(specIn.Left(i) + tmplate);
}
}
m_ClientNew.Empty();
// let the dialogbox know whether this is a new client or an edit of an existing one
int index= FindInListAll(m_Active.IsEmpty() ? pCmd->GetItemName() : m_Active);
if ((index == -1) || !GetItemCount()) // if name not in client list
index = m_NewClient ? -1 : -2; // it's new if and only if they clicked 'New'
pCmd->SetIsNewClient(m_isNew = (index == -1));
pCmd->SetIsRequestingNew(m_NewClicked);
pCmd->SetOldClient(m_OldClient);
pCmd->SetCaller(DYNAMIC_DOWNCAST(CView, GetParent()));
m_NewClicked = m_NewClient = FALSE; // clear these now, cuz no longer needed
if (m_AddToViewList.GetCount() > 0) // We have files to add to the Reviews list
{
CString specIn(pCmd->GetSpecIn());
int i;
if ((i = specIn.Find(_T("\n\nView:\n"))) == -1)
{
i = specIn.GetLength();
specIn += _T("\n\nView:\n");
}
else
specIn += _T("\[email protected]\[email protected]\n"); // A view that is @[TAB]@ means
// put a blank line in the list here.
POSITION pos;
CString filename;
CString localname;
BOOL b = GET_P4REGPTR()->UseDepotInClientView();
for (pos = m_AddToViewList.GetHeadPosition(); pos != NULL; )
{
filename = m_AddToViewList.GetNext(pos);
if ((i = filename.Find(_T("<contains no files or folders>"))) != -1)
filename = filename.Left(i-1) + _T("/...");
localname = CString ( _T("//") ) + GET_P4REGPTR()->GetP4Client();
if (!b && ((i = filename.Find(_T('/'), 2)) > 2))
localname += filename.Right(filename.GetLength() - i);
else
localname += filename.Right(filename.GetLength() - 1);
if (filename.Find(_T(' ')))
filename = _T('\"') + filename + _T('\"');
if (localname.Find(_T(' ')))
localname = _T('\"') + localname + _T('\"');
specIn += _T('\t') + filename + _T('\t') + localname + _T('\n');
}
m_AddToViewList.RemoveAll(); // this info is no longer needed
pCmd->SetSpecIn(specIn);
}
// show the dialog box
if(!pCmd->GetError() && !m_EditInProgress && pCmd->DoSpecDlg(this))
{
m_EditInProgress = TRUE;
m_EditInProgressWnd = pCmd->GetSpecSheet();
}
else
{
if (GET_P4REGPTR()->GetExpandFlag() == 1)
GET_P4REGPTR()->AddMRUPcuPath(MainFrame()->GetCurrentItemPath());
m_Active = m_OldClient;
GET_P4REGPTR()->SetP4Client( m_Active, TRUE, FALSE, FALSE);
MainFrame()->UpdateCaption( ) ;
delete m_pNewSpec;
if (pCmd->HaveServerLock())
pCmd->ReleaseServerLock();
delete pCmd;
}
MainFrame()->ClearStatus();
return 0;
}
示例7: cleanValue
CFieldValuePair::DumpARX(CARSConnection &arsConnect, CString Form, CStdioFile &File,
CString &strAttachDir, unsigned int *p_uiAttachNum,
CEntryId &EntryId, CString &strBuffer)
{
// Insert a space before the value
// File.Write(" ", 1);
strBuffer += " ";
CString cleanValue(Value);
// dump the value to the file
switch(uiType)
{
case AR_DATA_TYPE_NULL:
//File.Write("\"\"", 2);
strBuffer += "\"\"";
break;
// basically an value exported via this case will not have any double
// quotes exported
case AR_DATA_TYPE_INTEGER:
case AR_DATA_TYPE_REAL:
case AR_DATA_TYPE_ENUM:
case AR_DATA_TYPE_TIME:
case AR_DATA_TYPE_DECIMAL:
//File.Write(LPCSTR(Value), Value.GetLength()); // write the value
strBuffer += Value;
break;
// any value exported via this case will have double quotes
// inserted before and after the Value.
case AR_DATA_TYPE_CHAR:
case AR_DATA_TYPE_DIARY:
case AR_DATA_TYPE_CURRENCY: // treat currency like a char because we need to double quotes
cleanValue.Replace("\"", "\\\""); // insert a \ before each double quote
cleanValue.Replace("\n", "\\r\\n"); // replace carriage returns with \r\n text
//File.Write("\"", 1); // write double quote before value
strBuffer += "\"";
//File.Write(LPCSTR(cleanValue), cleanValue.GetLength()); // write the text value
strBuffer += cleanValue;
//File.Write("\"", 1); // write double quote after value
strBuffer += "\"";
break;
case AR_DATA_TYPE_ATTACH:
CString strExt; // working extenstion of the attachment
CString strFile; // working file name with no extension
CString strAttachNum; // working string for attachment number
CString strFinishedAttach; // working completed attachment name to use when calling GetEntryBLOB()
CString strFilePath; // the full path the the filename for saving the BLOB file
// Save the file extension
strExt = Value;
strExt.MakeReverse();
strExt = strExt.Left(4);
strExt.MakeReverse();
// Save the file name with out extenstion
strFile = Value.Left(Value.GetLength() - 4);
// convert the Attachment number to a string and increment it
strAttachNum.Format("%d", *p_uiAttachNum);
*p_uiAttachNum = *p_uiAttachNum + 1;
// build the completed attachment name to save
// strBuffer += "\"" + strAttachDir + "\\" + strFile + "_" + \
// strAttachNum + strExt + "\"";
strFinishedAttach = strAttachDir + "\\" + strFile + "_" + strAttachNum + strExt;
strBuffer += "\"" + strFinishedAttach + "\"";
// Lastly, save the attachment file BLOB
// This function call needs the full path\filename to save the BLOB
// this should be specified in strAttachFileName
strFilePath = File.GetFilePath();
strFilePath.Replace(File.GetFileName(), LPCSTR(strFinishedAttach)); // replace the filename with the relative attachment name
DumpAttachment(arsConnect, Form, EntryId, uiFieldId, strFilePath);
break;
} // end switch
}
示例8: ConvertSpecialChars
void CExport::ConvertSpecialChars(CString &strString)
{
strString.Replace( "@CR" , "\n" );
strString.Replace( "@TAB" , "\t" );
}
示例9: Encode
// strURL: URL to encode.
// bEncodeReserved: Encode the reserved characters
// for example the ? character, which is used many times
// for arguments in URL.
// so if we are encoding just a string containing Keywords,
// we want to encode the reserved characters.
// but if we are encoding a simple URL, we wont.
CString CURLEncode::Encode(CString strURL, BOOL bEncodeReserved/*=FALSE*/)
{
// First encode the % sign, because we are adding lots of it later...
strURL.Replace(_T("%"), toHex(__toascii(_T('%'))));
// Encdoe the reserved characters, if we choose to
if (bEncodeReserved)
{
for (int i=0; i<m_iReservedLen; i++)
{
strURL.Replace(CString(m_lpszReservedString[i]), toHex(__toascii(m_lpszReservedString[i])));
}
}
// Encode 'unsafe' characters
// see: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
for (int i=0; i<m_iUnsafeLen; i++)
{
strURL.Replace(CString(m_lpszUnsafeString[i]), toHex(__toascii(m_lpszUnsafeString[i])));
}
// Encode unprintable characters 0x00-0x1F, and 0x7F
for (char c=0x00; c<=0x1F; c++)
{
strURL.Replace(CString(c), toHex(c));
}
strURL.Replace(CString((char)0x7F), toHex(0x7F));
// Now encode all other unsafe characters
TCHAR tc=0;
WORD w=0;
CString nc;
// In this stage we do not want to convert:
// 1. Characters A-Z, a-z, 0-9, because they are safe.
// 2. The reserved characteres, we have already dealt with them;
// 3. The % character...
CString strDoNotReplace(m_lpszReservedString);
strDoNotReplace.Append(_T("%"));
for (int i=0; i<strURL.GetLength(); i++)
{
tc=strURL.GetAt(i);
if ((tc<_T('a') || tc>_T('z')) &&
(tc<_T('A') || tc>_T('Z')) &&
(tc<_T('0') || tc>_T('9')) &&
strDoNotReplace.Find(tc)<0)
{
w=toUTF8(tc);
nc=toHex(HIBYTE(w));
nc.Append(toHex(LOBYTE(w)));
strURL.Replace(CString(tc), nc);
// We have added 5 extra characters to the length of the string,
// So we can ignore them.
i+=5;
}
}
return strURL;
}
示例10: sizeof
void m_EdInputVO2::OnBnClickedOk()
{
char cQ[256] = "";
long Ind = 0;
SYSTEMTIME st;
ZeroMemory(&st, sizeof(st));
GetLocalTime(&st);
char cY[10] = "";
m_Dat.GetWindowText(cY, 10);
WORD wYear = atoi(cY);
if( wYear < 1900 || st.wYear < wYear )
{
AfxMessageBox("Год указан некорректно!");
m_Dat.SetFocus();
return;
}
if( st.wYear == wYear && st.wMonth < m_Cb.GetCurSel() + 1)
{
AfxMessageBox("Месяц введен некорректно!");
m_Cb.SetFocus();
return;
}
if( m_Check.GetCheck() )
{
FILE *f = fopen("html\\tmp.html", "w");
if( !f )
{
AfxMessageBox("Невозможно открыть файл для сохранения отчета");
return;
}
char ccc[5120] = "";
sprintf(cQ, "pTov_mkcRepHTMVO2 %d, '%.2d%.2d01'", g_iDep, wYear, m_Cb.GetItemData(m_Cb.GetCurSel()));
DBW.ExecSQL(cQ);
for( int i = 0; i < 256 && (g_sqlret = DBW.Fetch())!= SQL_NO_DATA && g_sqlret != SQL_ERROR; i++ )
{
DBW.GetData(1, SQL_C_CHAR, ccc, 5120, &Ind);
fprintf(f, "%s\n", ccc);
}
DBW.CloseCursor();
fclose(f);
ShellExecute(NULL, "open", "html\\tmp.html", NULL, NULL, SW_SHOWNORMAL);
OnOK();
return;
}
char rpt[60000] = "";
char c = 0;
FILE *f = fopen("html\\vo2_template.htm", "r");
if( f )
{
c = fgetc(f);
int i;
for( i=0; i < 60000 && !feof(f); i++ )
{
rpt[i] = c;
c = fgetc(f);
}
fclose(f);
rpt[i] = 0;
}
else
{
AfxMessageBox ("Невозможно открыть шаблон vo2_template.htm\nФормирование невозможно");
return;
}
CString str = rpt;
strcpy(rpt, "N/A");
sprintf(cQ, "pTov_mkcRepSelVO2S %d, '%.2d%.2d01'", g_iDep, wYear, m_Cb.GetItemData(m_Cb.GetCurSel()));
DBW.ExecSQL(cQ);
DBW.Fetch();
DBW.GetData(1, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 ) str.Replace("###1###", rpt);
else str.Replace("###1###", "N/A");
DBW.GetData(2, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 )str.Replace("###2###", rpt);
else str.Replace("###2###", "N/A");
DBW.GetData(3, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 ) str.Replace("###3###", rpt);
else str.Replace("###3###", "N/A");
DBW.GetData(4, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 ) str.Replace("###4###", rpt);
else str.Replace("###4###", "N/A");
DBW.GetData(5, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 ) str.Replace("###5###", rpt);
else str.Replace("###5###", "N/A");
DBW.GetData(6, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 ) str.Replace("###6###", rpt);
else str.Replace("###6###", "N/A");
DBW.GetData(7, SQL_C_CHAR, rpt, 100, &Ind );
if( Ind != -1 )str.Replace("###7###", rpt);
else str.Replace("###7###", "N/A");
//.........这里部分代码省略.........
示例11: UpdateFunctionInDocument
BOOL CFunctionView::UpdateFunctionInDocument()
{
BOOL bRetVal = FALSE;
POSITION sStart = m_sStartPos;
if ( sStart != NULL )
{
CFunctionEditorDoc* pDoc = (CFunctionEditorDoc*)CView::GetDocument();
if ( pDoc != NULL )
{
SBUS_SPECIFIC_INFO sBusSpecInfo;
pDoc->bGetBusSpecificInfo(sBusSpecInfo);
//Construct the Function Footer
CString omStrFnFooter;
// If it is global variable then select Global variable footer
if( m_omStrFnName == GLOBAL_VARIABLES )
{
omStrFnFooter = BUS_VAR_FOOTER;
omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
}
else
{
// Select function common footer
omStrFnFooter = EDITOR_BUS_FN_FOOTER;
// Form function specific footer
omStrFnFooter.Replace("PLACE_HODLER_FOR_BUSNAME", sBusSpecInfo.m_omBusName);
omStrFnFooter.Replace( "PLACE_HODLER_FOR_FUNCTIONNAME",
m_omStrFnName );
}
CString omStrLine("");
// Get the Edit control ref.
CRichEditCtrl& romEditCtrl = GetRichEditCtrl();
// get the total lines of code in the rich edit control
int nLineCount = romEditCtrl.GetLineCount();
long lStart, lEnd;
// Get the cursor position
romEditCtrl.GetSel(lStart, lEnd);
// Get the cursor line and save
m_nCurrentLine = (int) romEditCtrl.LineFromChar(lStart);
BOOL bDone = FALSE;
pDoc->m_omSourceCodeTextList.GetNext(sStart);
POSITION sPos1 = NULL;
POSITION sPos2 = NULL;
for( sPos1 = sStart; ( ((sPos2 = sPos1) != NULL) && (!bDone) ); )
{
CString omStrDel =
pDoc->m_omSourceCodeTextList.GetNext( sPos1 );
if( omStrDel.Find(omStrFnFooter) >= 0 )
{
bDone = TRUE;
}
else
{
pDoc->m_omSourceCodeTextList.RemoveAt( sPos2 );
}
}
BOOL bFirst = TRUE;
POSITION sPos = m_sStartPos;
for (int nLineIndex = 0; nLineIndex < nLineCount; nLineIndex++)
{
CString omStrNewItem("");
int nCharIndex = GetRichEditCtrl().LineIndex(nLineIndex);
int nLineLength = GetRichEditCtrl().LineLength(nCharIndex);
nLineLength = ( nLineLength < 4 ) ? 4 : nLineLength;
GetRichEditCtrl().GetLine(nLineIndex,
omStrNewItem.GetBuffer(nLineLength),
nLineLength);
omStrNewItem.ReleaseBuffer(nLineLength);
omStrNewItem.TrimRight();
if ( bFirst )
{
pDoc->m_omSourceCodeTextList.SetAt(sPos, omStrNewItem);
bFirst = FALSE;
}
else
{
pDoc->m_omSourceCodeTextList.InsertAfter(
sPos, omStrNewItem);
pDoc->m_omSourceCodeTextList.GetNext(sPos);
}
}
bRetVal = TRUE;
}
}
//.........这里部分代码省略.........
示例12: SendOverSMAPI
// This method sends the report over Simple MAPI
BOOL CErrorReportSender::SendOverSMAPI()
{
strconv_t strconv;
if(g_CrashInfo.m_sEmailTo.IsEmpty())
{
m_Assync.SetProgress(_T("No E-mail address is specified for sending error report over Simple MAPI; skipping."), 0);
return FALSE;
}
if(g_CrashInfo.m_bSilentMode)
{
m_Assync.SetProgress(_T("Simple MAPI may require user interaction (not acceptable for non-GUI mode); skipping."), 0);
return FALSE;
}
m_Assync.SetProgress(_T("Sending error report using Simple MAPI"), 0, false);
m_Assync.SetProgress(_T("Initializing MAPI"), 1);
BOOL bMAPIInit = m_MapiSender.MAPIInitialize();
if(!bMAPIInit)
{
m_Assync.SetProgress(m_MapiSender.GetLastErrorMsg(), 100, false);
return FALSE;
}
if(m_SendAttempt!=0)
{
m_Assync.SetProgress(_T("[confirm_launch_email_client]"), 0);
int confirm = 1;
m_Assync.WaitForFeedback(confirm);
if(confirm!=0)
{
m_Assync.SetProgress(_T("Cancelled by user"), 100, false);
return FALSE;
}
}
CString msg;
CString sMailClientName;
m_MapiSender.DetectMailClient(sMailClientName);
msg.Format(_T("Launching the default email client (%s)"), sMailClientName);
m_Assync.SetProgress(msg, 10);
m_MapiSender.SetFrom(g_CrashInfo.m_sEmailFrom);
m_MapiSender.SetTo(g_CrashInfo.m_sEmailTo);
m_MapiSender.SetSubject(g_CrashInfo.m_sEmailSubject);
CString sFileTitle = m_sZipName;
sFileTitle.Replace('/', '\\');
int pos = sFileTitle.ReverseFind('\\');
if(pos>=0)
sFileTitle = sFileTitle.Mid(pos+1);
m_MapiSender.SetMessage(FormatEmailText());
m_MapiSender.AddAttachment(m_sZipName, sFileTitle);
// Create and attach MD5 hash file
CString sErrorRptHash;
CalcFileMD5Hash(m_sZipName, sErrorRptHash);
sFileTitle += _T(".md5");
CString sTempDir;
Utility::getTempDirectory(sTempDir);
CString sTmpFileName = sTempDir +_T("\\")+ sFileTitle;
FILE* f = NULL;
_TFOPEN_S(f, sTmpFileName, _T("wt"));
if(f!=NULL)
{
LPCSTR szErrorRptHash = strconv.t2a(sErrorRptHash.GetBuffer(0));
fwrite(szErrorRptHash, strlen(szErrorRptHash), 1, f);
fclose(f);
m_MapiSender.AddAttachment(sTmpFileName, sFileTitle);
}
BOOL bSend = m_MapiSender.Send();
if(!bSend)
m_Assync.SetProgress(m_MapiSender.GetLastErrorMsg(), 100, false);
else
m_Assync.SetProgress(_T("Sent OK"), 100, false);
return bSend;
}
示例13: ParseAndInsertProjectProperty
bool CHooks::ParseAndInsertProjectProperty( hooktype t, const CString& strhook, const CTSVNPath& wcRootPath, const CString& rootPath, const CString& rootUrl, const CString& repoRootUrl )
{
if (strhook.IsEmpty())
return false;
// the string consists of multiple lines, where one hook script is defined
// as four lines:
// line 1: command line to execute
// line 2: 'true' or 'false' for waiting for the script to finish
// line 3: 'show' or 'hide' on how to start the hook script
// line 4: 'force' on whether to ask the user for permission
hookkey key;
hookcmd cmd;
key.htype = t;
key.path = wcRootPath;
int pos = 0;
CString temp;
temp = strhook.Tokenize(L"\n", pos);
if (!temp.IsEmpty())
{
ASSERT(t == GetHookType(temp));
temp = strhook.Tokenize(L"\n", pos);
if (!temp.IsEmpty())
{
int urlstart = temp.Find(L"%REPOROOT%");
if (urlstart >= 0)
{
temp.Replace(L"%REPOROOT%", repoRootUrl);
CString fullUrl = temp.Mid(urlstart);
int urlend = -1;
if ((urlstart > 0)&&(temp[urlstart-1]=='\"'))
urlend = temp.Find('\"', urlstart);
else
urlend = temp.Find(' ', urlstart);
if (urlend < 0)
urlend = temp.GetLength();
fullUrl = temp.Mid(urlstart, urlend-urlstart);
fullUrl.Replace('\\', '/');
// now we have the full url of the script, e.g.
// https://svn.osdn.net/svnroot/tortoisesvn/trunk/contrib/hook-scripts/client-side/checkyear.js
CString sLocalPathUrl = rootUrl;
CString sLocalPath = rootPath;
// find the lowest common ancestor of the local path url and the script url
while (fullUrl.Left(sLocalPathUrl.GetLength()).Compare(sLocalPathUrl))
{
int sp = sLocalPathUrl.ReverseFind('/');
if (sp < 0)
return false;
sLocalPathUrl = sLocalPathUrl.Left(sp);
sp = sLocalPath.ReverseFind('\\');
if (sp < 0)
return false;
sLocalPath = sLocalPath.Left(sp);
}
// now both sLocalPathUrl and sLocalPath can be used to construct
// the path to the script
CString partUrl = fullUrl.Mid(sLocalPathUrl.GetLength());
if (partUrl.Find('/') == 0)
partUrl = partUrl.Mid(1);
if (sLocalPath.ReverseFind('\\') == sLocalPath.GetLength() - 1 || sLocalPath.ReverseFind('/') == sLocalPath.GetLength() - 1)
sLocalPath = sLocalPath.Left(sLocalPath.GetLength() - 1);
sLocalPath = sLocalPath + L"\\" + partUrl;
sLocalPath.Replace('/', '\\');
// now replace the full url in the command line with the local path
temp.Replace(fullUrl, sLocalPath);
}
urlstart = temp.Find(L"%REPOROOT+%");
if (urlstart >= 0)
{
CString temp2 = temp;
CString sExt = rootUrl.Mid(repoRootUrl.GetLength());
CString sLocalPath;
do
{
temp = temp2;
CString repoRootUrlExt = repoRootUrl + sExt;
int slp = sExt.ReverseFind('/');
if (slp >= 0)
sExt = sExt.Left(sExt.ReverseFind('/'));
else if (sExt.IsEmpty())
return false;
else
sExt.Empty();
temp.Replace(L"%REPOROOT+%", repoRootUrlExt);
CString fullUrl = temp.Mid(urlstart);
int urlend = -1;
if ((urlstart > 0)&&(temp[urlstart-1]=='\"'))
urlend = temp.Find('\"', urlstart);
else
urlend = temp.Find(' ', urlstart);
if (urlend < 0)
urlend = temp.GetLength();
fullUrl = temp.Mid(urlstart, urlend-urlstart);
fullUrl.Replace('\\', '/');
// now we have the full url of the script, e.g.
// https://svn.osdn.net/svnroot/tortoisesvn/trunk/contrib/hook-scripts/client-side/checkyear.js
//.........这里部分代码省略.........
示例14: ProcessMenu
//.........这里部分代码省略.........
str=**init;
// processing menuitem - find the text
int iPos=str.Find(_T("\""), 0);
CString strText;
if (iPos != -1)
{
strText=str.Mid(iPos+1);
int iPos2=strText.Find(_T("\""));
if (iPos2 != -1)
strText=strText.Left(iPos2);
}
// now find the | that separates the text from the pseudo-ID
int iBar=strText.ReverseFind(_T('|'));
if (iBar != -1)
{
// there is a text with an ID
CString strID=strText.Mid(iBar+1);
strText=strText.Left(iBar);
// put the id and text in the translation file
// find the equiv for the id
UINT uiID = GetResourceID(strID);
pElementMap->insert(std::make_pair(uiID, strText));
// put the found ID as output text
CString out;
out.Format(_T("\"%lu\""), uiID);
str=str.Left(iPos)+out;
}
else
{
// no pseudoID in menu name
str=str.Left(iPos)+_T("\"P\"");
}
m_vOutRCFile.push_back(str);
(*init)++;
ProcessMenu(uiMenuID, init);
}
else
{
// if the line has MENUITEM
if (str.Left(8) == _T("MENUITEM") && str.Right(9) != _T("SEPARATOR"))
{
// restore original
str=**init;
// check if there is any text after the comma
int iPos=str.Find(_T(","), 0);
CString strTest=str.Mid(iPos);
strTest.TrimLeft(_T(" ,\t\r\n"));
if (strTest.IsEmpty())
{
(*init)++;
CString tmp=**init;
tmp.Trim(_T(" ,\t\r\n"));
str+=tmp;
}
// processing menuitem - find the text
iPos=str.Find(_T("\""), 0);
CString strText;
if (iPos != -1)
{
strText=str.Mid(iPos+1);
int iPos2=strText.Find(_T("\""));
if (iPos2 != -1)
strText=strText.Left(iPos2);
}
// find the ID
iPos=str.Find(_T(","), 0);
CString strID;
if (iPos != -1)
{
strID=str.Mid(iPos+1);
int iPos2=strID.Find(_T(","), 0);
if (iPos2 != -1)
strID=strID.Left(iPos2);
}
strID.TrimLeft(_T(" \t"));
strID.TrimRight(_T(" \t"));
// find the equiv for the id
UINT uiID = GetResourceID(strID);
pElementMap->insert(std::make_pair(uiID, strText));
CString out = str;
// out=**init;
out.Replace(_T("\"")+strText+_T("\""), _T("\"i\""));
m_vOutRCFile.push_back(out);
}
else
m_vOutRCFile.push_back(**init);
}
}
}
示例15: AutoLoadFiles
void CPlaylistItem::AutoLoadFiles()
{
if (m_fns.IsEmpty()) {
return;
}
const CAppSettings& s = AfxGetAppSettings();
CString fn = m_fns.GetHead();
if (s.fAutoloadAudio && fn.Find(_T("://")) < 0) {
int i = fn.ReverseFind('.');
if (i > 0) {
const CMediaFormats& mf = s.m_Formats;
CString ext = fn.Mid(i + 1).MakeLower();
if (!mf.FindExt(ext, true)) {
CString path = fn;
path.Replace('/', '\\');
path = path.Left(path.ReverseFind('\\') + 1);
WIN32_FIND_DATA fd;
ZeroMemory(&fd, sizeof(WIN32_FIND_DATA));
HANDLE hFind = FindFirstFile(fn.Left(i) + _T("*.*"), &fd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
continue;
}
CString fullpath = path + fd.cFileName;
CString ext2 = fullpath.Mid(fullpath.ReverseFind('.') + 1).MakeLower();
if (!FindFileInList(m_fns, fullpath) && ext != ext2
&& mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow)) {
m_fns.AddTail(fullpath);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
}
}
if (s.IsISRAutoLoadEnabled()) {
const CString& pathList = s.strSubtitlePaths;
CAtlArray<CString> paths;
int pos = 0;
do {
CString path = pathList.Tokenize(_T(";"), pos);
if (!path.IsEmpty()) {
paths.Add(path);
}
} while (pos != -1);
CString dir = fn;
dir.Replace('\\', '/');
int l = dir.ReverseFind('/') + 1;
int l2 = dir.ReverseFind('.');
if (l2 < l) { // no extension, read to the end
l2 = fn.GetLength();
}
CString title = dir.Mid(l, l2 - l);
paths.Add(title);
CAtlArray<Subtitle::SubFile> ret;
Subtitle::GetSubFileNames(fn, paths, ret);
for (size_t i = 0; i < ret.GetCount(); i++) {
if (!FindFileInList(m_subs, ret[i].fn)) {
m_subs.AddTail(ret[i].fn);
}
}
}
}