In my MFC application i have a derived CDHtmlDialog class that opens a login screen and i need to get a url and a cookie from the server after a redirect.
I navigate to
Finally figured it out.
Inside the CDHtmlDialog class the OnNavigateComplete method is responsible for assigning value to m_spHtmlDoc but since i overwritten the method no ones assign value to the document, not even the OnDocumentComplete so the simple solution is
void CDHtmlDlgPersonalizado::OnNavigateComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{
/*CALL THE PARENT METHOD*/
CDHtmlDialog::OnNavigateComplete(pDisp, szUrl);
/*Now GetDHtmlDocument will get the value from m_spHtmlDoc and assign to spHtmlDoc*/
IHTMLDocument2Ptr spHtmlDoc = nullptr;
this->GetDHtmlDocument(&spHtmlDoc);
if (spHtmlDoc != nullptr)
{
BSTR bstr = ::SysAllocString(L" ");
spHtmlDoc->get_cookie(&bstr);
}
}