CHtmlView Navigate2 and ExecWB Execution

自古美人都是妖i 提交于 2019-12-02 08:12:16

I found out a way to end the problem with Print and Print Preview after Navigate(). As user1793036 mentioned it is an asynchrous call and I need to wait for that operation to complete. This is the reason that the Print Preview and Print is loading an empty page.

I found the event OnNavigateComplete2() and overridden as below for the hassle free Print/preview operations.

void CMyHtmlView::OnNavigateComplete2(LPCTSTR strURL)
{
    if(m_ePrintMode == PREVIEW)
        ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER, NULL, NULL );
    else if(m_ePrintMode == PRINT)
        CHtmlView::OnFilePrint();
    else
        return;
}

And modified my Print and Print Preview events as

void CMyHtmlView::OnFilePrintPreview()
{
    OnSaveHtmlReport();

    m_ePrintMode = PREVIEW; // an Enum

    Navigate2(m_sFileName);
}

void CMyHtmlView::OnFilePrint()
{
    OnSaveHtmlReport();

    m_ePrintMode = PRINT; // an Enum

    Navigate2(m_sFileName,NULL,NULL);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!