当前位置: 首页>>代码示例>>C++>>正文


C++ CComQIPtr::CreateMarkupPointer方法代码示例

本文整理汇总了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);
		}
	}
开发者ID:GordonSmith,项目名称:eclide,代码行数:39,代码来源:WebPage.cpp

示例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;
	}
开发者ID:GordonSmith,项目名称:eclide,代码行数:40,代码来源:WebPage.cpp


注:本文中的CComQIPtr::CreateMarkupPointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。