Hello all,

I recently found out about the Mozilla Active X control and since it was 
supposed to be adrop-in replacement for the IE control, I downloaded it 
to check it out.

While the basics seemd to work, it wasn't quite a drop-in replacement 
for me. On eproblem was trgar it doesn't support the the res protocol. 
In my Windows app I have the basic HTML page defined as a resource and I 
could just tell the IE control

m_pBrowser->Navigate(_bstr_t("res://MultiBible.exe/135"), NULL, NULL, 
NULL, NULL);

and that basic page page would show. This was minor thing, however, 
since I could just use the IHTMLDocument2::write() method instead.

However, a non-minor problem was that the Mozilla control did not like 
the IHTMLDocument2::get_body() method. I use the basic HTML doc to set 
up what things are going to look like with a <style> tag, and then 
whenever that data that needs to be shown is changed I use get_body() to 
return a pointer an IHTMLElement object for the <body> tag and the use 
IHTMLElements put_innerHTML, put_innerText() and insertAdjacentHTML to 
first clear everything inside the <body> tag and then add the new data. 
The code looks like this:

void CHtmlWindow::ClearBody()
{
    IHTMLDocument2 *phtml = NULL;
    IHTMLElement *pbody = NULL;

    phtml = GetDocument();
    if (phtml != NULL) {
        phtml->get_body(&pbody);
        if (pbody) {
            pbody->put_innerHTML(_bstr_t(L""));
            pbody->put_innerText(_bstr_t(L""));
        }
                phtml->Release();
    }
}

int CHtmlWindow::AddLine(LPWSTR lpszLine)
{
    IHTMLDocument2 *phtml = NULL;
    IHTMLElement *pbody = NULL;
    HRESULT hr;
    BSTR line = _bstr_t(lpszLine);

    phtml = GetDocument();
    if (phtml != NULL) {
        hr = phtml->get_body(&pbody);
        if (pbody) {
            hr = pbody->insertAdjacentHTML(_bstr_t("beforeEnd"), line);
        }
        phtml->Release();
    }
    return 0;
}

It all works perfectly in the IE control, but in AddLine() the line 
phtml->get_body(&pbody); causes my app to crash when I use the Mozilla 
control and ClearBody() was called just before. If I comment out the 
ClearBody() call, then the phtml->get_body() works but 
pbody->insertAdjacentHTML() returns 0x80004001. (I have no idea what 
that value means, but in WinError.h there is the comment "Invalid advise 
flags" just before the #define of OLE_E_ADVF as that value.)

First off, why would IHTMLDocument2::get_body() crash after after using 
the code in ClearBody()? The <body> tag may be empty, but it is still 
there. Second, why would IHTMLDocument2::insertAdjacentHTML() fail to 
add the new HTML? Anybody have nay ideas?

Thanks in advance.

--
Cory Albrecht
http://www.sentex.net/~corya/
_______________________________________________
mozilla-embedding mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-embedding

Reply via email to