本文整理汇总了C++中CComQIPtr::CreateMarkupPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::CreateMarkupPointer方法的具体用法?C++ CComQIPtr::CreateMarkupPointer怎么用?C++ CComQIPtr::CreateMarkupPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::CreateMarkupPointer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepRequest
static void PrepRequest(IHTMLDocument * doc, ClassifyStructVector & request)
{
CComQIPtr<IMarkupContainer> markupContainer = doc;
CComQIPtr<IMarkupServices> markupServices = markupContainer;
CComPtr<IMarkupPointer> finger;
CComPtr<IMarkupPointer> prev;
CComPtr<IMarkupPointer> end;
markupServices->CreateMarkupPointer(&finger);
markupServices->CreateMarkupPointer(&prev);
markupServices->CreateMarkupPointer(&end);
finger->MoveToContainer(markupContainer, true);
prev->MoveToContainer(markupContainer, true);
end->MoveToContainer(markupContainer, false);
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);
}
}
finger->IsRightOfOrEqualTo(end, &finished);
}
}
示例2: InsertScript
bool InsertScript(IHTMLDocument * doc, const CComBSTR & scriptText)
{
if (CComQIPtr<IHTMLDocument3> doc3 = doc)
{
CComPtr<IHTMLElementCollection> pNodes;
doc3->getElementsByTagName(L"head", &pNodes);
long length = 0;
pNodes->get_length(&length);
if(length == 1)
{
CComPtr<IDispatch> pDisp2;
pNodes->item(CComVariant(0), CComVariant(0), &pDisp2);
CComQIPtr<IHTMLDOMNode> headNode = pDisp2;
CComQIPtr<IHTMLElement> headElement = pDisp2;
CComQIPtr<IMarkupServices> muServ = doc;
CComPtr<IMarkupPointer> lhs;
CComPtr<IMarkupPointer> rhs;
muServ->CreateMarkupPointer(&lhs);
muServ->CreateMarkupPointer(&rhs);
CComPtr<IHTMLElement> scriptElement;
doc3->getElementById(L"LNBandScript", &scriptElement);
if (!scriptElement)
{
lhs->MoveAdjacentToElement(headElement, ELEM_ADJ_BeforeEnd);
rhs->MoveAdjacentToElement(headElement, ELEM_ADJ_BeforeEnd);
CComPtr<IHTMLElement> newScript;
muServ->CreateElement(TAGID_SCRIPT, L"id=\"LNBandScript\" language=\"javascript\" type=\"text/javascript\"", &newScript);
CComQIPtr<IHTMLScriptElement> script = newScript;
script->put_text(scriptText);
HRESULT result = muServ->InsertElement(newScript, lhs, rhs);
ATLASSERT(result == S_OK);
}
return true;
}
}
return false;
}