I am trying to use
HRESULT GetDHtmlDocument(IHTMLDocument2 **pphtmlDoc);
function in MFC programming.
Basically, I am t
Your calling to GetDHtmlDocument()
and GetElement()
will return E_NOINTERFACE
.
According to my knowledge, you are not always guaranteed to have html document completely loaded when you're performing in CDHtmlDialog::OnInitDialog()
.
Instead, you should override CDHtmlDialog::OnDocumentComplete()
in CSampleProgramDlg
. It's a callback function that'll be called when document is loaded. You can assess the document then.
void CSampleProgramDlg::OnDocumentComplete(
LPDISPATCH pDisp,
LPCTSTR szUrl
)
{
// You can get the document and elements here safely
}
Your calling to MessageBox()
may somehow trigger the document to be loaded in advance. Though I'm not 100% sure for it.
Hope that helps.