CHtmlView and Printing
Hi Everyone,
The CHtmlView is giving me alot of head aches. Here is what I am doing. I
am opening an XML file (being formatted using XLST) in a hidden CHtmlView
and printing it.
Here is how the process goes:
1. I create the XML file on the fly.
2. load the XML file in to CHtmlView.
3. Once loaded I tell it to print the resulting HTML page.
4, I need to delete XML file after the printing is done. (this is the
problem).
I can't figure out how to find out when the CHtmlView is done printing.
CHtmlView::OnFilePrint is asynchronous. And CHtmlView doesn't tell me that
it is currently printing.
(Note: Navigate methods are also asynchronous but you can figure out that
it's not done loading using CHtmlView::GetBusy().)
Here is the code I have so far
ASSERT(m_pPrintView && m_pPrintView->GetSafeHwnd());
CString Filename;
char Buffer[200];
GetCurrentDirectory(200,Buffer);
Filename.Format("%sReports\\%ld.xml",Buffer,GetTickCount());
//generates the XML Document
LSActivityPrinter Printer(GetDocument()->GetActivity(),this);
Printer.PrinterEditor(Filename,Dlg.m_PrintClues,Dlg.m_PrintFact,Dlg.m_PrintC
ode);
//load the XML file
m_pPrintView->Navigate2(Filename);
//wait while it is loading the XML file
while (m_pPrintView->GetBusy())
{
//pump messages while waiting.
((CLSEditorApp *)AfxGetApp())->Yeild();
}
//tell it to print the HTML File
m_pPrintView->OnFilePrint();
while (m_pPrintView->GetBusy())
{
((CLSEditorApp *)AfxGetApp())->Yeild();
}
//delete the XML and any supporting Jpgs
Printer.Cleanup();
AliR.