刪除string類型字串中指定字串段

來源:互聯網
上載者:User

標籤:style   資料   os   資料庫   sql   window   

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();

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.