Puzzling OnInitialUpdate() behavior for CHtmlView derived class
-
Here is my code :-
void CReportView::OnInitialUpdate()
{
Navigate2(_T("about:blank"),NULL,NULL);IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument(); if(!pDoc) { return; } HRESULT hr; SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1); VARIANT \*param; MessageBox("L"); // If I comment out this line it fails BSTR bsData = m\_html.AllocSysString(); hr = SafeArrayAccessData(psa, (LPVOID\*)¶m); param->vt = VT\_BSTR; param->bstrVal = bsData; hr = pDoc->write(psa); hr = pDoc->close(); SysFreeString(bsData); SafeArrayDestroy(psa);
}
You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Here is my code :-
void CReportView::OnInitialUpdate()
{
Navigate2(_T("about:blank"),NULL,NULL);IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument(); if(!pDoc) { return; } HRESULT hr; SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1); VARIANT \*param; MessageBox("L"); // If I comment out this line it fails BSTR bsData = m\_html.AllocSysString(); hr = SafeArrayAccessData(psa, (LPVOID\*)¶m); param->vt = VT\_BSTR; param->bstrVal = bsData; hr = pDoc->write(psa); hr = pDoc->close(); SysFreeString(bsData); SafeArrayDestroy(psa);
}
You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
Okay, this is a sorta make-shift work-around :-)
void CReportView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();Navigate2(\_T("about:blank"),NULL,NULL);
}
That's all :-) Now I have my own
void CReportView::RenderView()
{
...
...
}This has sorta solved the issue. I call RenderView when I want to change the contents Nish :~
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
-
Here is my code :-
void CReportView::OnInitialUpdate()
{
Navigate2(_T("about:blank"),NULL,NULL);IHTMLDocument2 \*pDoc=(IHTMLDocument2 \*)GetHtmlDocument(); if(!pDoc) { return; } HRESULT hr; SAFEARRAY\* psa = SafeArrayCreateVector(VT\_VARIANT, 0, 1); VARIANT \*param; MessageBox("L"); // If I comment out this line it fails BSTR bsData = m\_html.AllocSysString(); hr = SafeArrayAccessData(psa, (LPVOID\*)¶m); param->vt = VT\_BSTR; param->bstrVal = bsData; hr = pDoc->write(psa); hr = pDoc->close(); SysFreeString(bsData); SafeArrayDestroy(psa);
}
You can see the MessageBox call there. If the MessageBox is there, it works right and shows the html rendering of the source contained in m_html which is a CString. If I remove the MessageBox, the html comes rightly for about 0.005 seconds [approximate guess] and then it becomes blank :-( Regards Nish
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]
An off topic question - how did you get your code snippet nicely formatted? Gavin
-
An off topic question - how did you get your code snippet nicely formatted? Gavin
Using the PRE tag :-)
Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]