Problems to print
-
Hi All I have problems to send print in my application. If I send print and if I change my view before ready to print, all commands will be cancelled. I send direct to print, print setup is not showed, the view can be closed, and OpenDocumentFile doesn't show this view if command is print; My application needs fill a graph, reading from a database, while not read all data he is not ready to print, I have a flag to do this. See my code:
//if the document was found, try to print it
if(pDoc!=NULL)
{
//if document is ready for printing, print it now
dwTick=::GetTickCount();
nPrintWindowTimeout=5;
if(nPrintWindowTimeout<0)
nPrintWindowTimeout=0;
dwWaitLimit=(DWORD)nPrintWindowTimeout*1000;
if(pDoc->IsReadyForPrintWindow() || (dwTick < item.m_dwTickStart || dwTick - item.m_dwTickStart > dwWaitLimit) )
{
//remove screen from the queue
m_arPrintQueue.RemoveAt(0);
//print
pDoc->SetPrinting(TRUE);
if (pDoc->GetView())
{
if (item.m_bPrintSetup == TRUE)
pDoc->GetView()->SendMessage(WM_COMMAND, ID_FILE_PRINT_SETUP);
else
// But if I change my view this is never executed, the message queue is not keeping this in another view
// This is sended in a CView, not in MainFrame, my derived CView process WM_COMMAND
pDoc->GetView()->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}
pDoc->SetPrinting(FALSE);
pDoc->OnCloseDocument();
}
}
}Somebody, can help me? Thank you