Главная страница | назад





Article #15983: using TPrintOut

 Question and Answer Database
FAQ983C.txt using TPrintOut
Category :OWL
Platform :All
Product :BC++ 5.x
Question:
I have a sample MDI application program that will allow me to
open/create a new text file(s). I'd like to be able to print
these files but when I tried to run (execute 'Print' menu item),
it crashed. Would anyone tell me what I've done wrong here. Any
pointer is appreciated. Here is what I have :
class TMyApp : public TApplication {
public:
...
TPrinter* Printer;
TMDIClient* MdiClient;
void CmFilePrint();
virtual void InitMainWindow;
DECLARE_RESPONSE_TABLE(TMyApp);
}
=====
DEFINE_RESPONSE_TABLE(TMyApp,TApplication)
EV_COMMAND(CM_FILEPRINT,CmFilePrint),
...
END_RESPONSE_TABLE;
//
void TMyApp::InitMainWindow()
{
...
MdiClient = new TMDIClient;
TDecoratedMDIFrame* frame = new TDecoratedMDIFrame(Name, IDM_MDI,
*MdiClient, false);
...
}
void TMyApp::CmFilePrint()
{
if( !Printer)
Printer = new TPrinter;
TPrintout printout("Printer Output...");
Printer->Print(this,printout,true);
}
Answer:
TPrintOut is an abstract base class. You need to derive your own
class from TPrintOut and atleast override the PrintPage() method.
Check out the help and the printing example in
\Examples\Owl\Classes\Printing\printing.ide
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99