CHtmlView Navigate2 and ExecWB Execution

后端 未结 1 831
迷失自我
迷失自我 2021-01-24 01:57

This is Linking to my previous question.

I have managed to make a new view derived from the CHtmlView for the new type of View for the my application generat

相关标签:
1条回答
  • 2021-01-24 02:14

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