本文整理汇总了C++中CComQIPtr::EnumObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::EnumObjects方法的具体用法?C++ CComQIPtr::EnumObjects怎么用?C++ CComQIPtr::EnumObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::EnumObjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartClassify
void StartClassify(const CComBSTR & scriptText)
{
clib::recursive_mutex::scoped_lock proc(m_mutex);
if (m_classified)
{
proc.unlock();
on_refresh(this, EVENT_CLASSIFIED);
return;
}
m_classified = true;
ClassifyStructVector request;
//Process Main Frame
InsertScript(m_doc, scriptText);
PrepRequest(m_doc, request);
//Process Child Frames
CComQIPtr<IOleContainer> pContainer = m_doc;
if (!pContainer)
return;
CComPtr<IEnumUnknown> pEnumerator;
HRESULT hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
if (FAILED(hr))
return;
CComPtr<IUnknown> pUnk;
ULONG uFetched;
for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
{
CComQIPtr<IWebBrowser2> pBrowser = pUnk;
if (pBrowser)
{
CComPtr<IDispatch> spDispDoc;
HRESULT hr = pBrowser->get_Document(&spDispDoc);
if (SUCCEEDED(hr))
{
// ...and query for an HTML document.
CComQIPtr<IHTMLDocument> spHTMLDoc = spDispDoc;
if (spHTMLDoc)
{
InsertScript(spHTMLDoc, scriptText);
PrepRequest(spHTMLDoc, request);
}
}
}
pUnk.Release();
}
m_classifyThreads.SetMaxThreadCount(0);
ClassifyStructVector batchRequest;
int textLen = 0;
for(ClassifyStructVector::iterator itr = request.begin(); itr != request.end(); ++itr)
{
textLen += itr->text.length();
batchRequest.push_back(*itr);
if (textLen > BATCH_SIZE)
{
m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
batchRequest.clear();
textLen = 0;
}
}
if (batchRequest.size())
{
m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, batchRequest));
batchRequest.clear();
}
m_classifyThreads.SetMaxThreadCount(THREAD_COUNT);
//int textLen = 0;
//BOOL finished = false;
//HRESULT hr = S_OK;
//while(hr == S_OK && !finished)
//{
// MARKUP_CONTEXT_TYPE pContext = CONTEXT_TYPE_None;
// long pcch = -1;
// prev->MoveToPointer(finger);
// hr = finger->Right(true, &pContext, NULL, &pcch, NULL);
// if (pContext == CONTEXT_TYPE_Text && pcch > 1)
// {
// ClassifyStruct newItem;
// newItem.text.resize(pcch);
// prev->Right(false, NULL, NULL, &pcch, &newItem.text[0]);
// std::wstring testStr = newItem.text;
// boost::algorithm::trim(testStr);
// if (testStr.length())
// {
// markupServices->CreateMarkupPointer(&newItem.textNode);
// newItem.textNode->MoveToPointer(prev);
// request.push_back(newItem);
// textLen += pcch;
// if (textLen > 1000)
// {
// m_classifyThreads.Append(__FUNCTION__, boost::bind(&threadClassify, this, request));
// request.clear();
// textLen = 0;
// }
// }
// }
// finger->IsRightOfOrEqualTo(end, &finished);
//.........这里部分代码省略.........
示例2: FS
void
CFrame::UpdateLinks()
{
// start from scratch
m_ChildFrames.clear();
// detect all child frames
CComQIPtr<IOleContainer> spContainer = m_Document;
if (!!spContainer)
{
// get an enumerator for the frames
IEnumUnknown* pEnumerator;
HRESULT hr = spContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
if (SUCCEEDED(hr))
{
IUnknown* pUnknown;
ULONG uFetched;
// enumerate all the frames
for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnknown, &uFetched); i++)
{
CComQIPtr<IWebBrowser2> spChildBrowser = pUnknown;
pUnknown->Release();
if (!!spChildBrowser)
{
// well done, store child frame
CComPtr<IDispatch> spChildDispDoc;
CHECK_COM(spChildBrowser->get_Document(&spChildDispDoc), FS(_T("Cannot retrieve document object from %08X"), spChildBrowser));
CComQIPtr<IHTMLDocument2> spChildDoc = spChildDispDoc;
// sometimes IE can return NULL spChildDispDoc
//
// (observed on pages with file download blocking)
// test for valid doc
if (!!spChildDoc)
{
CComBSTR url2;
CHECK_COM(spChildDoc->get_URL(&url2), FS(_T("Cannot retrieve location URL from %08X"), spChildDoc));
CString URL2 = url2;
// it wouldn't be so easy to simply add child document into childs
// but IE (maybe) does some reallocation of this document, so we need to do lookup via frameId
TFrameId id = m_FrameTable.GetFrameId(spChildDoc, false);
// wait for document to load,
// there is RISK OF CALLS to other functions !!!
//if (id==NULL_FRAME) id = m_FrameTable.GetFrameId(spChildDoc, true); // blocking call
if (id==NULL_FRAME)
{
// TODO: tohle se muze nekdy stat, kdyz se frame jeste nestihne naloadovat pri F5, napriklad gmail.com to dela
TRACE_W(FS(_T("Child doc not found for %s !!"), URL2));
}
else
{
m_ChildFrames.push_back(id);
}
}
}
}
}
pEnumerator->Release();
}
}