Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to Change Displayed HTML with CHtmlView?

71 views
Skip to first unread message

Jim Howard

unread,
Feb 2, 2003, 7:47:34 PM2/2/03
to

I'm working on an MFC SDI app using CHtmlView as the main view. The
application loads the following html code in the OnInitialUpdate member
using Navigate2:

<code> <!- just for this posting ->
<html>
<head>
<title>HTMLPAGE2.htm</title>
</head>
<body>
<P id="hello">Hello World</P>
<form id="ScanRequest" method="post">
<INPUT id="Submit1" type="submit" value="Submit" name="Submit1">
</form>
</body>
</html>
</code>

When the submit button is replaced, I want to replace the displayed code
with new html, so in my OnBeforeNavigate2 member I have this code:

void CHTMLTest2View::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags,
LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders,
BOOL* pbCancel)

{

IHTMLElement* pBody = NULL;

CComQIPtr<IHTMLDocument2> pDoc = GetHtmlDocument();

if(pDoc)

{

BSTR oldbody;

pDoc->get_body(&pBody);

CComBSTR newbody("<body><br><br>goodbye world</body>");

pBody->get_innerHTML(&oldbody);

CString strold(oldbody);

HRESULT hr = pBody->put_innerHTML((BSTR)newbody); // hr always is equal
to S_OK after the submit

pBody->Release();


}

// Calling the base class doesn't seem to make a difference, I've tried it
with and without the next statement

// CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName,
baPostedData, lpszHeaders, pbCancel);

}

Everything I've read seems to imply that this code should change the
displayed view on the SDI app, but nothing is happening. I've moved this
code around in some of the other functions, but nothing seems to work. What
simple thing am I failing to grasp?? I want to be able to change the
display with loading new html and reloading if that's possible.

Thanks,

Jim Howard

jn...@spamcop.net


Jeff Partch

unread,
Feb 2, 2003, 8:06:53 PM2/2/03
to
I'm just making stuff up, Jim -- so don't be suprised if this just
wastes your time, but have you tried setting...

*pbCancel = TRUE;

--
Jeff Partch [VC++ MVP]


"Jim Howard" <jn...@spamcop.net> wrote in message
news:u3IFL3xyCHA.2600@TK2MSFTNGP11...

Jim Howard

unread,
Feb 2, 2003, 8:16:51 PM2/2/03
to
Jeff,

THAT WAS IT!!!!!! I had a "d'oh" moment as soon as I saw it. Now my code
works just as I hoped!

Thank you so much.

Jim Howard


"Jeff Partch" <je...@mvps.org> wrote in message
news:e6bf#ByyCHA.1776@TK2MSFTNGP09...

0 new messages