March 31st, 2002, 01:39 AM
[MFC] Browsing the HTML DOM in C++
Hi all, this is a problem I've been struggling with for about two weeks or so, and I can't seem to find any resources to help me that don't assume you have a PhD in computer lingo. If you saw my similar question, please forgive this thread. I'm just so very stumped, and figured I had to give it one last try, in case some one who know this stuff didn't see my post at the end of my other thread.
I'm not going to post much code, since I may be going wrong really early on. Consider this: I have my CHTMLView derived view for my application. In its OnNavigateComplete2 function, I get the IDispatch pointer to the HTML Document, and query it for the interface to the HTML Document:
This is pretty much all that I know is definitely working. I need to do alot of things from the SetElements function, but for now, I'll settle with being able to read the name/value of any single element in the collection. For the life of me, I can't seem to do it. My problem, I believe, is I don't know how to use the proper string classes. I can't figure out what to do with functions prototyped like:
void CMyHtmlView::OnNavigateComplete2(LPCTSTR strURL)
// Get the document's IDispatch pointer.
IDispatch* pIDisp = GetHtmlDocument();
// Obtain a pointer to the IHTMLDocument2 interface.
IHTMLDocument2* pIHTMLDoc2 = NULL;
hr = pIDisp->QueryInterface(IID_IHTMLDocument2, (void**) &pIHTMLDoc2);
if (SUCCEEDED (hr))
void CMyHtmlView::GetHTMLElements(IHTMLDocument2* p)
// Obtain a pointer to the HTMLElements interface.
IHTMLElementCollection* pIHTMLElements = NULL;
hr = p->get_all(&pIHTMLElements);
I know I'm in over my head here, but I really want to do this. I spent an hour or so at the bookstore, trying to find a good book to help me, but they're all rather advanced, and basically geared to people who want to learn how to write COM interfaces and such. I have no desire to do that, I only want to learn how to *use* this interface (I'm not a programmer by trade). COM and ATL come up alot in the literature I've seen. Is knowing these things really necessary to do what I want to do?