Get cookie from CDHtmlDialog

前端 未结 1 420
野的像风
野的像风 2021-01-26 21:26

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

相关标签:
1条回答
  • 2021-01-26 21:50

    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);
        }
    }
    
    0 讨论(0)
提交回复
热议问题