zoukankan      html  css  js  c++  java
  • 删除string类型字符串中指定字符串段

    1.实现背景

      在插入list行时用邮件的MessageID给对应行命名。

      在回复全部邮件时,收件人变为之前收件人中出去“自己”同时加入之前发件人,抄送人还是之前的抄送人,密送人不用管,直接不用带。

      在“回复全部”按钮响应函数里面

        CListUI* pList = static_cast<CListUI*>(m_PaintManager.FindControl(_T("middle_comlumn_header1")));//拿到list控件指针
                int index = pList->GetCurSel();//获取当前选中行
                CControlUI* pControl = pList->GetItemAt(index);//获取对应行控件指针
                string strMsgID = UTF(pControl->GetName().GetData());//获取对应行控件名字

                const char* gszFile ="WebMail.sqlite";
                CppSQLite3DB *pDB=new CppSQLite3DB;
                pDB->open(gszFile);

                string strSql;
                strSql="SELECT mFrom,mTo,mCc,mSubject FROM Email where mMessageID ='";//在数据库里面查到对应mMessageID记录
                strSql+= strMsgID;
                strSql+="'";
                CppSQLite3Query query=pDB->execQuery(strSql.c_str());

                string StrFrom,StrTo,StrCC,StrSub,temp;
                StrFrom = query.getStringField("mFrom");
                StrTo=query.getStringField("mTo");
                temp=m_Imap.ms_User;//要除去的目标字符串
        
                int pos = StrTo.find(temp,0);//找到目标字符串所在位置
                StrTo=StrTo.substr(0,pos-1)+StrTo.substr(pos+temp.length(),StrTo.length()-(pos+temp.length()));
                StrTo+=";";
                StrTo+=StrFrom;

                StrCC=query.getStringField("mCc");

                StrSub=query.getStringField("mSubject");
                StrSub.insert(0,"RE: ");
                query.finalize();
                pDB->close();

                vector<string> data;
                data.push_back(StrTo);
                data.push_back(StrCC);
                data.push_back(StrSub);


                CWriteWnd* pWrite=new CWriteWnd(_T("WriteWnd.xml"),m_Imap,data);

                pWrite->Create(NULL, _T("WriteWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
                pWrite->CenterWindow();
                pWrite->ShowModal();

  • 相关阅读:
    病历管理系统(附源码)
    2013年未之wpf项目乱述
    非农行情的做单策略
    Open Source Trading Platforms ( who needs mt4 ?)
    【原创】如何获得近10年的1分钟完整历史数据并导入MT4
    MetaTrader 4客户端的秘密
    六张图教你交易美国5月非农数据
    创业手札
    如果想开公司,你必须了解这些!!创业的人收藏吧!!
    如何开设港股和美股投资账户
  • 原文地址:https://www.cnblogs.com/chechen/p/3818990.html
Copyright © 2011-2022 走看看