Fail to PrintContext without CDialog.DoModal call previously

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I have to recompile a MFC++ Program developped under NT4.0 in XP. We store
the printer settings (DEVMODE and DEVNAMES) as part of our document. When
printing in batch mode, we need to create a PrintingContext without asking
the user. Here is my code fragment (I removed all error handling):

BOOL CTsprintView::OnPreparePrinting(CPrintInfo* pInfo) {
// we get DEVMODE and DEVNAMES from the document...
....
pDoc->setContext(pInfo);
// now pInfo->m_pPD->m_pd.hDevMode and
// pInfo->m_pPD->m_pd.hDevNames are set.

// now we create the context:
pInfo->m_pPD->CreatePrinterDC();
return true;
}

when starting the program as above, nothing gets printed. (And I see no
error messages). When I change the last line to

pInfo->m_pPD->DoModal();

the dialog gets popped up correcty with the right settings and printing
works as expected.

Any hints/help is welcome.

Thanks
Jürg
 
Oups, I was not totally correct, I may do get some error messages:

instead of printing, I get strange files with names like:

IP_10.0.0.1««««««««îþîþîþîþîþîþ

in my working directory. What do these files mean?
 
Back
Top