本文整理汇总了C++中SStringW::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ SStringW::GetLength方法的具体用法?C++ SStringW::GetLength怎么用?C++ SStringW::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SStringW
的用法示例。
在下文中一共展示了SStringW::GetLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CRect
LRESULT SSkinImgFrame2::OnAttrSrc(const SStringW & strValue,BOOL bLoading)
{
int iPos = strValue.Find(L'{');
if(iPos==-1) return E_FAIL;
m_strImgKey = strValue.Left(iPos);
SStringW strRgn = strValue.Right(strValue.GetLength()-iPos);
if(swscanf(strRgn,L"{%d,%d,%d,%d}",&m_rcImg.left,&m_rcImg.top,&m_rcImg.right,&m_rcImg.bottom)!=4)
{
CPoint pt;
CSize sz;
if(swscanf(strRgn,L"{%d,%d,@%d,@%d}",&pt.x,&pt.y,&sz.cx,&sz.cy)!=4)
return E_FAIL;
m_rcImg = CRect(pt,sz);
}
IMGPOOL::CPair * p = s_imgPool.Lookup(m_strImgKey);
if(p)
{
SSkinImgFrame::SetImage(p->m_value);
p->m_value->AddRef();
}else
{
IBitmap *pImg=LOADIMAGE2(m_strImgKey);
if(!pImg) return E_FAIL;
s_imgPool[m_strImgKey]=pImg;
SSkinImgFrame::SetImage(pImg);
}
return S_OK;
}
示例2: InitMenuItemData
void SMenu::InitMenuItemData(SMenuItemInfo & itemInfo, const SStringW & strTextW)
{
itemInfo.strText=S_CW2T(TR(strTextW,m_menuAttr.m_strTrCtx));
//查找快捷键
int iHotKey = strTextW.Find(L"&");
if(iHotKey != -1 && iHotKey < strTextW.GetLength()-1)
{
itemInfo.vHotKey = tolower(strTextW[iHotKey+1]);
}else
{
itemInfo.vHotKey = 0;
}
}
示例3: toString
SStringW SLayoutSize::toString() const
{
SStringW strValue = SStringW().Format(L"%f",fSize);
//去掉sprintf("%f")生成的小数点最后无效的0
LPCWSTR pszData = strValue;
for(int i=strValue.GetLength()-1;i>=0;i--)
{
if(pszData[i]!=L'0')
{
if(pszData[i]==L'.') i--;
strValue = strValue.Left(i+1);
break;
}
}
return SStringW().Format(L"%s%s",strValue,s_pszUnit[unit]);
}
示例4: 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;
}
示例5: _InsertFormatText
int SChatEdit::_InsertFormatText(int iCaret,CHARFORMATW cf,pugi::xml_node xmlText,BOOL bCanUndo)
{
SStringW strText = xmlText.value();
if(xmlText.name() == KLabelSmiley)
{//insert smiley
SComPtr<ISoSmileyCtrl> pSmiley;
HRESULT hr=::CoCreateInstance(CLSID_CSoSmileyCtrl,NULL,CLSCTX_INPROC,__uuidof(ISoSmileyCtrl),(LPVOID*)&pSmiley);
if(FAILED(hr)) return 0;
SComPtr<IRichEditOle> ole;
if(SSendMessage(EM_GETOLEINTERFACE,0,(LPARAM)(void**)&ole) && ole)
{
SComPtr<IRichEditOleCallback> pCallback;
hr=ole->QueryInterface(IID_IRichEditOleCallback,(void**)&pCallback);
if(FAILED(hr)) return 0;
SComPtr<ISmileyHost> host;
hr = pCallback->QueryInterface(__uuidof(ISmileyHost),(void**)&host);
if(FAILED(hr)) return 0;
SComPtr<ISmileySource> pSource;
hr = host->CreateSource(&pSource);
if(FAILED(hr)) return 0;
{
UINT uID = xmlText.attribute(L"id").as_uint(-1);
SStringW strPath = xmlText.attribute(L"path").value();
if(uID != -1)
hr = pSource->LoadFromID(uID);
else
hr = pSource->LoadFromFile(strPath);
if(SUCCEEDED(hr))
{
pSmiley->SetSource(pSource);
SSendMessage(EM_SETSEL,iCaret,iCaret);
pSmiley->Insert2Richedit((DWORD_PTR)(void*)ole);
}
}
}
return SUCCEEDED(hr)?1:0;
}
CHARFORMATW cfNew = cf;
cfNew.dwMask = 0;
if(xmlText.name() == KLabelColor)
{
cfNew.crTextColor = StringToColor(xmlText.attribute(L"value").value()) & 0x00ffffff;
cfNew.dwMask |= CFM_COLOR;
}else if(xmlText.name()== KLabelFont)
{
wcscpy(cf.szFaceName,cfNew.szFaceName);
wcscpy_s(cfNew.szFaceName,LF_FACESIZE-1,xmlText.attribute(L"value").value());
cfNew.dwMask |= CFM_FACE;
}else if(xmlText.name()==KLabelUnderline)
{
cfNew.dwMask |=CFM_UNDERLINE;
cfNew.dwEffects |= CFE_UNDERLINE;
}else if(xmlText.name() == KLabelItalic)
{
cfNew.dwMask |=CFM_ITALIC;
cfNew.dwEffects |= CFE_ITALIC;
}else if(xmlText.name() == KLabelBold)
{
cfNew.dwMask |=CFM_BOLD;
cfNew.dwEffects |= CFE_BOLD;
}else if(xmlText.name() == KLabelStrike)
{
cfNew.dwMask |= CFM_STRIKEOUT;
cfNew.dwEffects |= CFE_STRIKEOUT;
}else if(xmlText.name() == KLabelLink)
{
cfNew.dwMask |= CFM_LINK;
cfNew.dwEffects |= CFE_LINK;
COLORREF cr = StringToColor(xmlText.attribute(L"color").value());
if(cr!=0)
{
cfNew.dwMask |= CFM_COLOR;
cfNew.crTextColor = cr & 0x00ffffff;
}
}else if(xmlText.name() == KLabelSize)
{
cfNew.dwMask |= CFM_SIZE;
HDC hdc=GetDC(NULL);
LONG yPixPerInch = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL,hdc);
cfNew.yHeight = abs(MulDiv(xmlText.attribute(L"value").as_uint(12), LY_PER_INCH, yPixPerInch));
}
int nRet = strText.GetLength();
SSendMessage(EM_REPLACESEL,bCanUndo,(LPARAM)(LPCWSTR)strText);
int iEnd = iCaret + nRet;
SSendMessage(EM_SETSEL,iCaret,iEnd);
SSendMessage(EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cfNew);
iCaret = iEnd;
SSendMessage(EM_SETSEL,iCaret,iCaret);
pugi::xml_node xmlChild = xmlText.first_child();
while(xmlChild)
{
int nSubLen = _InsertFormatText(iCaret,cfNew,xmlChild,bCanUndo);
iCaret += nSubLen;
//.........这里部分代码省略.........
示例6: ExecuteScript
VARIANT ExecuteScript(IWebBrowser2 *pWebBrowser, const SStringW & fun,SArray<SStringW> & params)
{
VARIANT varErr;
VariantInit( &varErr );
//get document dispatch interface
IDispatch* pDisp = NULL;
HRESULT hr = pWebBrowser->get_Document( &pDisp );
if ( FAILED( hr ) || pDisp == NULL )
{
return varErr;
}
IHTMLDocument2* pDoc = NULL;
pDisp->QueryInterface( IID_IHTMLDocument2,(void**)&pDoc );
pDisp->Release();
IDispatch* pScript = NULL;
hr = pDoc->get_Script( &pScript );
pDoc->Release();
if ( FAILED( hr ) || pScript == NULL )
{
return varErr;
}
sbstr bstrMember((int)fun.GetLength(),fun );
DISPID dispid = 0;
BSTR bstr = (BSTR)bstrMember;
hr = pScript->GetIDsOfNames( IID_NULL,&(bstr),1,LOCALE_SYSTEM_DEFAULT,&dispid );
if ( FAILED( hr ) )
{
return varErr;
}
DISPPARAMS dispparams;
::ZeroMemory( &dispparams,sizeof( DISPPARAMS ) );
dispparams.cArgs = (UINT)params.GetCount();
dispparams.rgvarg = new VARIANT[dispparams.cArgs];
dispparams.cNamedArgs = 0;
for ( size_t i = 0;i < params.GetCount();i++ )
{
size_t indx = params.GetCount() - i - 1;
sbstr bstrParam((int)params[indx].GetLength(),params[indx]);
dispparams.rgvarg[i].bstrVal = bstrParam.Release();
dispparams.rgvarg[i].vt = VT_BSTR;
}
EXCEPINFO excepinfo;
::ZeroMemory( &excepinfo,sizeof( EXCEPINFO ) );
VARIANT varRet;
UINT nArgErr = (UINT)-1; //initialize to invalid arg
hr = pScript->Invoke( dispid,IID_NULL,0,DISPATCH_METHOD,&dispparams,&varRet,&excepinfo,&nArgErr );
delete []dispparams.rgvarg;
pScript->Release();
if ( FAILED( hr ) )
{
return varErr;
}
return varRet;
}