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 generated reports but I find soem problem in the new View
class CMyHtmlView : public CHtmlView
{
protected: // create from serialization only
CMyHtmlView();
DECLARE_DYNCREATE(CMyHtmlView)
// Attributes
public:
CReportDoc* GetDocument();
CString m_sFileName;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyHtmlView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual void OnFilePrintPreview();
virtual void OnFilePrint();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyHtmlView();
//{{AFX_MSG(CMyHtmlView)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
void CMyHtmlView::OnFilePrintPreview()
{
// Before this I will call a Function Generate a HTML File in a Location and Updated in m_sFileName
Navigate2(m_sFileName);
ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_PROMPTUSER, NULL, NULL );
}
void CMyHtmlView::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
Navigate2(_T("about:blank"));
}
void CMyHtmlView::OnFilePrint()
{
// Before this I will call a Function Generate a HTML File in a Location and Updated in m_sFileName
Navigate2(m_sFileName,NULL,NULL);
CHtmlView::OnFilePrint();
}
In this Printing OnFilePrint() is working without any problem. But the problem exists in the OnFilePrintPreview().
Here is the problem:
On Calling ExecWB() after a Navigate() makes only the HTML view based Window in the App, no print preview window been shown
Am I doing anything wrong?
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.
And modified my Print and Print Preview events as