本文整理汇总了C++中SStringW::GetBufferSetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ SStringW::GetBufferSetLength方法的具体用法?C++ SStringW::GetBufferSetLength怎么用?C++ SStringW::GetBufferSetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SStringW
的用法示例。
在下文中一共展示了SStringW::GetBufferSetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFormatText
SStringW SChatEdit::GetFormatText()
{
SStringW strTxt;
TEXTRANGE txtRng;
txtRng.chrg.cpMin =0;
txtRng.chrg.cpMax = SSendMessage(WM_GETTEXTLENGTH);
txtRng.lpstrText = (LPTSTR)strTxt.GetBufferSetLength(txtRng.chrg.cpMax);
SSendMessage(EM_GETTEXTRANGE,0,(LPARAM)&txtRng);
strTxt.ReleaseBuffer();
SComPtr<IRichEditOle> ole;
SSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)(void**)&ole);
SStringW strMsg;
int iPlainTxtBegin = 0;
for(int i=0;i<strTxt.GetLength();i++)
{
if(strTxt[i] == 0xfffc)
{//找到一个OLE对象
strMsg += strTxt.Mid(iPlainTxtBegin,i-iPlainTxtBegin);
iPlainTxtBegin = i+1;
REOBJECT reobj={sizeof(reobj),0};
reobj.cp = i;
HRESULT hr = ole->GetObject( REO_IOB_USE_CP , &reobj, REO_GETOBJ_POLEOBJ);
if(SUCCEEDED(hr) && reobj.poleobj)
{
if(reobj.clsid == CLSID_CSoSmileyCtrl)
{
SComPtr<ISoSmileyCtrl> smiley;
hr = reobj.poleobj->QueryInterface(__uuidof(ISoSmileyCtrl), (void**)&smiley);
if(SUCCEEDED(hr))
{
SComPtr<ISmileySource> source;
hr = smiley->GetSource(&source);
SASSERT(SUCCEEDED(hr));
UINT uID = -1;
SStringW strSmiley = L"<smiley";
if(SUCCEEDED(source->GetID(&uID)))
{
strSmiley += SStringW().Format(L" id=\"%d\"",uID);
}
BSTR strFile;
if(SUCCEEDED(source->GetFile(&strFile)))
{
strSmiley += SStringW().Format(L" path=\"%s\"",strFile);
::SysFreeString(strFile);
}
strSmiley += L"/>";
strMsg += strSmiley;
}
}
reobj.poleobj->Release();
}
}
}
if(iPlainTxtBegin<strTxt.GetLength())
{
strMsg += strTxt.Right(strTxt.GetLength()-iPlainTxtBegin);
}
return strMsg;
}