本文整理汇总了C++中CComBSTR::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ CComBSTR::Length方法的具体用法?C++ CComBSTR::Length怎么用?C++ CComBSTR::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComBSTR
的用法示例。
在下文中一共展示了CComBSTR::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NodeExistsInParent
BOOL NodeExistsInParent(CComPtr<ItcProjectNode> owner_node, CComBSTR name) {
_ASSERT( owner_node != NULL );
if ((name.Length() > 0) && FAILED(name.ToLower()))
return FALSE;
CComPtr<ItcProjectNodeIterator> iterator;
if (FAILED( owner_node->CreateChildIterator(&iterator) )) {
return FALSE;
}
while (iterator->HasNext() == VARIANT_TRUE) {
CComPtr <ItcProjectNode> node;
if (FAILED( iterator->Next(&node) )) {
return FALSE;
}
CComBSTR caption;
if (SUCCEEDED( node->get_Caption(&caption) )) {
if ((caption.Length() == 0) || SUCCEEDED(caption.ToLower())) {
if (caption == name) {
return TRUE;
}
}
}
}
return FALSE;
}
示例2: SaveWhiteboardSettingsData
/****************************************
** Author: Joe Li
** Purpose: Save whiteboard settings data
** Comments:
****************************************/
bool DOSaveAppData::SaveWhiteboardSettingsData(const CComBSTR& sourcePath, const CComBSTR& targetPath)
{
if (sourcePath.Length() != 0 && targetPath.Length() != 0)
{
const unsigned long bufferSize = 256;
TCHAR buffer[bufferSize];
DOPersistentFile sourceFile;
// Search for first source file
if (sourceFile.FindFirstFile(sourcePath, WHITEBOARD_SETTINGS_WILDCARD_SEARCH, buffer, bufferSize) == true)
{
CComBSTR sourceFileName = buffer;
bool allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath);
// Search of remaining source file(s)
while (sourceFile.FindNextFile(buffer, bufferSize) == true)
{
sourceFileName = buffer;
allWhiteboardSettingsSaved = SaveWhiteboardSettings(sourcePath, sourceFileName, targetPath) && allWhiteboardSettingsSaved;
}
return allWhiteboardSettingsSaved;
}
}
return false;
}
示例3: get_targetElement
Element* ElementAnimation::get_targetElement()
{
return m_targetElement;
#if 0
// Try targetElement attribute
CComBSTR targetElement;
static_cast<T*>(this)->getAttribute(L"targetElement", &targetElement);
if (targetElement.Length() > 0)
{
static_cast<T*>(this)->m_ownerDocument->getElementById(targetElement, pVal);
if (*pVal) return S_OK;
}
// Try href:xlink attribute
CComBSTR href;
static_cast<T*>(this)->getAttributeNS(WSTR("http://www.w3.org/1999/xlink"), WSTR("href"), &href);
if (href.Length())
{
if (((BSTR)href)[0] == L'#')
{
BSTR id = &((BSTR)href)[1];
static_cast<T*>(this)->m_ownerDocument->getElementById(id, pVal);
if (*pVal) return S_OK;
}
}
// Try parent element
CComPtr<ILDOMNode> parentNode;
static_cast<T*>(this)->get_parentNode(&parentNode);
CComQIPtr<Element, &IID_Element> parentElement((IUnknown*)parentNode);
*pVal = parentElement.Detach();
return NULL;
#endif
}
示例4: get_AccountDispenser
HRESULT CPigEngine::get_AccountDispenser(IPigAccountDispenser** ppDispenser)
{
// Get the computer name of the account server
CComBSTR bstrServer;
RETURN_FAILED(get_AccountServer(&bstrServer));
if (!bstrServer.Length())
{
// Get the computer name of the mission server
RETURN_FAILED(get_MissionServer(&bstrServer));
}
// Check for '.' to indicate this computer
if (1 == bstrServer.Length() && OLESTR('.') == bstrServer[0])
bstrServer.Empty();
// Create the Pig Account Dispenser on the mission server
COSERVERINFO si = {0, bstrServer, NULL, 0};
MULTI_QI mqi = {&IID_IPigAccountDispenser, NULL, S_OK};
RETURN_FAILED(CoCreateInstanceEx(CLSID_PigAccountDispenser, NULL,
CLSCTX_SERVER, &si, 1, &mqi));
// Copy the interface pointer to the [out] parameter
ZSucceeded(mqi.hr);
*ppDispenser = (IPigAccountDispenser*)mqi.pItf;
// Indicate success
return S_OK;
}
示例5: FindUsedColumns
bool CSaveModifiedItemsDialog::FindUsedColumns(ITabbedMDIChildModifiedList* list, int columnUseCount[eColumn_Count])
{
if(list == NULL)
{
return false;
}
bool success = true;
long count = 0;
list->get_Count(&count);
for(long i=0; i<count; ++i)
{
CComPtr<ITabbedMDIChildModifiedItem> item;
list->get_Item(i, &item);
if(item)
{
if(m_showColumn[eColumn_Name])
{
CComBSTR displayName;
item->get_DisplayName(&displayName);
if(displayName.Length() > 0)
{
columnUseCount[eColumn_Name] += 1;
}
}
if(m_showColumn[eColumn_Description])
{
CComBSTR description;
item->get_Description(&description);
if(description.Length() > 0)
{
columnUseCount[eColumn_Description] += 1;
}
}
if(m_showColumn[eColumn_LastModified])
{
DATE lastModified = 0;
item->get_LastModifiedUTC(&lastModified);
if(lastModified != 0)
{
columnUseCount[eColumn_LastModified] += 1;
}
}
CComPtr<ITabbedMDIChildModifiedList> subItems;
item->get_SubItems(&subItems);
if(subItems)
{
this->FindUsedColumns(subItems, columnUseCount);
}
}
}
return success;
}
示例6: CPropertyPage
CPPageFileInfoClip::CPPageFileInfoClip(CString fn, IFilterGraph* pFG)
: CPropertyPage(CPPageFileInfoClip::IDD, CPPageFileInfoClip::IDD)
, m_fn(fn)
, m_clip(ResStr(IDS_AG_NONE))
, m_author(ResStr(IDS_AG_NONE))
, m_copyright(ResStr(IDS_AG_NONE))
, m_rating(ResStr(IDS_AG_NONE))
, m_location_str(ResStr(IDS_AG_NONE))
, m_album(ResStr(IDS_AG_NONE))
, m_hIcon(NULL)
{
BeginEnumFilters(pFG, pEF, pBF) {
if (CComQIPtr<IPropertyBag> pPB = pBF) {
if (!((CMainFrame*)AfxGetMainWnd())->CheckMainFilter(pBF)) {
continue;
}
CComVariant var;
if (SUCCEEDED(pPB->Read(CComBSTR(_T("ALBUM")), &var, NULL))) {
m_album = var.bstrVal;
}
}
if (CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
if (!((CMainFrame*)AfxGetMainWnd())->CheckMainFilter(pBF)) {
continue;
}
CComBSTR bstr;
if (SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length()) {
m_clip = bstr.m_str;
bstr.Empty();
}
if (SUCCEEDED(pAMMC->get_AuthorName(&bstr)) && bstr.Length()) {
m_author = bstr.m_str;
bstr.Empty();
}
if (SUCCEEDED(pAMMC->get_Copyright(&bstr)) && bstr.Length()) {
m_copyright = bstr.m_str;
bstr.Empty();
}
if (SUCCEEDED(pAMMC->get_Rating(&bstr)) && bstr.Length()) {
m_rating = bstr.m_str;
bstr.Empty();
}
if (SUCCEEDED(pAMMC->get_Description(&bstr)) && bstr.Length()) {
m_descText = bstr.m_str;
m_descText.Replace(_T(";"), _T("\r\n"));
bstr.Empty();
}
}
}
EndEnumFilters;
}
示例7: SetGroupTitleImage
//------------------------------------------------------------------------
//! Update the image icon in the group header together with top and bottom
//! description. Microsoft encourage people not to use this functionality.
//!
//! @param nGroupId ID of the group
//! @param nImage Index of the title image in the control imagelist.
//! @param strTopDesc Description text placed oppposite of the image
//! @param strBottomDesc Description text placed below the top description
//! @return Succeeded in updating the group image
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::SetGroupTitleImage(int nGroupId, int nImage, const CString& strTopDesc, const CString& strBottomDesc)
{
if (!IsGroupStateEnabled())
return FALSE;
#if _WIN32_WINNT >= 0x0600
LVGROUP lg = {0};
lg.cbSize = sizeof(lg);
lg.mask = LVGF_TITLEIMAGE;
lg.iTitleImage = nImage; // Index of the title image in the control imagelist.
#ifdef UNICODE
if (!strTopDesc.IsEmpty())
{
// Top description is drawn opposite the title image when there is
// a title image, no extended image, and uAlign==LVGA_HEADER_CENTER.
lg.mask |= LVGF_DESCRIPTIONTOP;
lg.pszDescriptionTop = (LPWSTR)(LPCTSTR)strTopDesc;
lg.cchDescriptionTop = strTopDesc.GetLength();
}
if (!strBottomDesc.IsEmpty())
{
// Bottom description is drawn under the top description text when there is
// a title image, no extended image, and uAlign==LVGA_HEADER_CENTER.
lg.mask |= LVGF_DESCRIPTIONBOTTOM;
lg.pszDescriptionBottom = (LPWSTR)(LPCTSTR)strBottomDesc;
lg.cchDescriptionBottom = strBottomDesc.GetLength();
}
#else
CComBSTR bstrTopDesc = strTopDesc;
CComBSTR bstrBottomDesc = strBottomDesc;
if (!strTopDesc.IsEmpty())
{
lg.mask |= LVGF_DESCRIPTIONTOP;
lg.pszDescriptionTop = bstrTopDesc;
lg.cchDescriptionTop = bstrTopDesc.Length();
}
if (!strBottomDesc.IsEmpty())
{
lg.mask |= LVGF_DESCRIPTIONBOTTOM;
lg.pszDescriptionBottom = bstrBottomDesc;
lg.cchDescriptionBottom = bstrBottomDesc.Length();
}
#endif
if (SetGroupInfo(nGroupId, (PLVGROUP)&lg)==-1)
return FALSE;
return TRUE;
#else
return FALSE;
#endif
}
示例8: OnPaint
LRESULT CVideoViewControl::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
PAINTSTRUCT ps = { 0 };
CDCHandle cdc(BeginPaint(&ps));
if (m_bPlayerStarted && m_strLastErrorMsg.IsEmpty())
{
::SendMessage(m_hWndPlayer, WM_PLAYER_UPDATE, 0, 0);
}
else
{
CRect rect;
GetClientRect(&rect);
static DWORD dwBrushColor = 0;
static DWORD dwTextColor = 0;
if (!dwBrushColor)
{
CComPtr<IThemeColorMap> pThemeColorMap;
ASSERT_IF_FAILED(m_pTheme->GetColorMap(&pThemeColorMap));
ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::BrushBackground, &dwBrushColor));
ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::PictureWindowText, &dwTextColor));
}
cdc.SetBkMode(TRANSPARENT);
cdc.SetTextColor(dwTextColor);
cdc.FillSolidRect(&rect, dwBrushColor);
CComBSTR str = L"Launching video player...";
if (!m_strLastErrorMsg.IsEmpty())
str = m_strLastErrorMsg;
CSize size;
CRect rect1 = rect;
cdc.DrawTextEx(str, str.Length(), &rect1, DT_WORDBREAK | DT_CENTER | DT_CALCRECT, NULL);
size.cx = rect1.Width();
size.cy = rect1.Height();
auto x = (rect.right - rect.left) / 2 - (size.cx / 2);
auto y = (rect.bottom - rect.top) / 2 - (size.cy / 2);
CRect rectText(x, y, x + size.cx, y + size.cy);
DrawRoundedRect(cdc, rectText, false);
cdc.DrawTextEx(str, str.Length(), &rectText, DT_WORDBREAK | DT_CENTER, NULL);
}
EndPaint(&ps);
return 0;
}
示例9: GetElementText
BOOL SimpleBrowser::GetElementText(LPCTSTR elementName, LPTSTR bf, UINT bfLen)
{
IHTMLDocument3* pDocument = GetDocument3();
if (pDocument == NULL)
return FALSE;
BOOL bRet = FALSE;
IHTMLElement* pElement = NULL;
CComBSTR elemName = elementName;
if (pDocument->getElementById(elemName, &pElement) == S_OK && pElement != NULL)
{
CComBSTR innerText;
if (pElement->get_innerText(&innerText) == S_OK)
{
if (innerText.Length() > 0)
{
_tcsncpy(bf, innerText, bfLen);
bf[bfLen - 1] = 0;
}
else
bf[0] = 0;
bRet = TRUE;
}
pElement->Release();
}
pDocument->Release();
return bRet;
}
示例10: SetGroupFooter
//------------------------------------------------------------------------
//! Update the description text of the group footer
//!
//! @param nGroupId ID of the group
//! @param strFooter The footer description text
//! @param dwAlign Indicates the alignment of the footer text for the group
//! @return Succeeded in updating the group footer
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::SetGroupFooter(int nGroupId, const CString& strFooter, DWORD dwAlign)
{
if (!IsGroupStateEnabled())
return FALSE;
#if _WIN32_WINNT >= 0x0600
LVGROUP lg = {0};
lg.cbSize = sizeof(lg);
lg.mask = LVGF_FOOTER | LVGF_ALIGN;
lg.uAlign = dwAlign;
#ifdef UNICODE
lg.pszFooter = (LPWSTR)(LPCTSTR)strFooter;
lg.cchFooter = strFooter.GetLength();
#else
CComBSTR bstrFooter = strFooter;
lg.pszFooter = bstrFooter;
lg.cchFooter = bstrFooter.Length();
#endif
if (SetGroupInfo(nGroupId, (PLVGROUP)&lg)==-1)
return FALSE;
return TRUE;
#else
return FALSE;
#endif
}
示例11: CreateEnumContext
HRESULT WpdObjectEnumerator::CreateEnumContext(
__inout ContextMap* pContextMap,
__in LPCWSTR pszParentID,
__deref_out_opt LPWSTR* ppszEnumContext)
{
HRESULT hr = S_OK;
GUID guidContext = GUID_NULL;
CComBSTR bstrContext;
EnumContext* pContext = NULL;
if((pContextMap == NULL) ||
(pszParentID == NULL) ||
(ppszEnumContext == NULL))
{
hr = E_POINTER;
CHECK_HR(hr, "Cannot have NULL parameter");
return hr;
}
*ppszEnumContext = NULL;
hr = CoCreateGuid(&guidContext);
if (hr == S_OK)
{
bstrContext = guidContext;
if(bstrContext.Length() == 0)
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to create BSTR from GUID");
}
}
if (hr == S_OK)
{
pContext = new EnumContext();
if(pContext != NULL)
{
CAtlStringW strKey = bstrContext;
pContext->ParentID = pszParentID;
hr = pContextMap->Add(strKey, pContext);
CHECK_HR(hr, "Failed to add enumeration context to client context map");
pContext->Release();
}
else
{
hr = E_OUTOFMEMORY;
CHECK_HR(hr, "Failed to allocate enumeration context");
}
}
if (hr == S_OK)
{
*ppszEnumContext = AtlAllocTaskWideString(bstrContext);
}
return hr;
}
示例12: SetMaxLength
void RichEditHost::SetMaxLength(uint nMaxLength)
{
if (m_dwMaxLength != nMaxLength)
{
m_dwMaxLength = nMaxLength;
if (m_pTextServices)
{
CComBSTR bsText;
if (m_pTextServices)
{
m_pTextServices->TxGetText(&bsText);
if (bsText.Length() > 0)
{
wstring wstrText = bsText;
if (wstrText.length() > m_dwMaxLength)
{
wstrText.erase(wstrText.begin() + m_dwMaxLength, wstrText.end());
m_pTextServices->TxSetText(wstrText.c_str());
}
}
}
LRESULT lRes = 0;
HRESULT hr = m_pTextServices->TxSendMessage(EM_EXLIMITTEXT, 0, nMaxLength, &lRes);
hr = m_pTextServices->OnTxPropertyBitsChange(TXTBIT_MAXLENGTHCHANGE, TXTBIT_MAXLENGTHCHANGE);
}
}
}
示例13: IntFromXML
int Skein::IntFromXML(IXMLDOMNode* node, LPWSTR query)
{
CComBSTR text = StringFromXML(node,query);
if (text.Length() > 0)
return _wtoi(text.m_str);
return 0;
}
示例14: switch
//////////////////////////////////////////////////////////////////////////////
// C[!output Safe_root]::GetPresetTitle
// Invoked when a host wants to obtain the title of the given preset
//////////////////////////////////////////////////////////////////////////////
STDMETHODIMP C[!output Safe_root]::GetPresetTitle(LONG nPreset, BSTR *bstrPresetTitle)
{
if (NULL == bstrPresetTitle)
{
return E_POINTER;
}
if ((nPreset < 0) || (nPreset >= PRESET_COUNT))
{
return E_INVALIDARG;
}
CComBSTR bstrTemp;
switch (nPreset)
{
case PRESET_BARS:
bstrTemp.LoadString(IDS_BARSPRESETNAME);
break;
case PRESET_SCOPE:
bstrTemp.LoadString(IDS_SCOPEPRESETNAME);
break;
}
if ((!bstrTemp) || (0 == bstrTemp.Length()))
{
return E_FAIL;
}
*bstrPresetTitle = bstrTemp.Detach();
return S_OK;
}
示例15: BoolFromXML
bool Skein::BoolFromXML(IXMLDOMNode* node, LPWSTR query, bool ifNon)
{
CComBSTR text = StringFromXML(node,query);
if (text.Length() > 0)
return wcscmp(text.m_str,L"YES") == 0;
return ifNon;
}