Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 10th, 2006, 05:51 PM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Manfred Send a message via Yahoo to Manfred
Default Problems with IHTMLDomNode and IHTMLElement

I am writing BHO for now, which dynamically changes the document.

I faced that thing, that if I do next (after the 'documentcomplete' event in browser)

Code:
//Code:
CComQIPtr<IHTMLElement> piSpanElement;
hr = pHtmlDocument->createElement(L"span", &piSpanElement);
BSTR innerHtml = L" [u]This is string with leading space"</u>";
//leading space is happily ignored, when I'm inserting that text:

hr = piSpanElement->put_innerHTML(innerHtml);

//Ok-ok, I beleive, it is with the good intentions 
//of MSHTML, I will try to insert some text... 
//I even do not put a whitespace there...

//Ok, I will try to insert some text... 
//(In MSDN  it is said, that InsertAdjancedText  inserts plain text.

hr = piSpanElement->insertAdjacentText(L"beforeEnd",L"Some text");

//OK, text is in element, but... I needed before content, ok, mistake - I try to correct:

hr = piSpanElement->insertAdjacentText(L"afterBegin",L"!I WANNA SEE THIS TEXT IN ELEMENT before content!");

//It does return S_OK... I do not see that text, WTH!?
//I insert this element simply querying interface and 
//substituting the DOM node. After that html element tortures.
May be I'm "stupido", but I cannot convert IHTMLDomNode element to the IHTMLElement. If there is any method - please tell..

then - one more...
we have "this node", reference node, and node to substitute
Substituting node is IHTMLDomNode pointer, former IHTMLDOMTextNode with text " " or any other - the result was same.

Code:
CComQIPtr<IHTMLDomNode> resultNode;
VARIANT refNode;

refNode.vt = VT_DISPATCH;
refNode.pdispVal = rNode; //reference node pointer

hr = thisNode->get_parentNode(&pNode); //parent node pointer
//OK, pNode is not null.
hr = pNode->InsertBefore(substitutingNode,refNode,&newNode);
//Why hr is EINVALIDARG???
or just simply - is there any way to insert that eaten leaded space.

Or what I do incorrectly?
 
Old May 10th, 2006, 02:21 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you find a solution?

I'm having a similar problem where I have added a node to the document, but it doesn't show up in the browser.

-joe

 
Old May 11th, 2006, 02:50 AM
Registered User
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Manfred Send a message via Yahoo to Manfred
Default

Joe Andrieu>

I told myself never code for IE...

What I did, to solve my problems:
to put adjanced nodes, I had to create IHTMLElement,
(From IHTMLDocument it does work).
Then, I put there apropriate innertext, Then convert to Dom Node,
then replacing existant.
Do not forget, that this is slightly not good, because you need to create some element, and you will have problems with leading spaces. (MSHtml will eat them).

IHTMLDOMNode have not interface to be converted to IHTMLElement.

--------------------
(null)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems already! KennySargent BOOK: Professional XNA Programming 2nd Edition ISBN: 978-0-470-26128-6 4 April 7th, 2008 03:36 AM
c problems saurabh1983in C++ Programming 6 November 29th, 2005 04:23 AM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
ie problems cat CSS Cascading Style Sheets 1 October 27th, 2004 10:46 PM
Two Problems goraya C# 2 May 21st, 2004 05:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.