Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing and second doc/view type

Status
Not open for further replies.

classT

Programmer
Oct 6, 2002
19
US
Hi all,

I have a MDI project where I have added a second document/view type. Everything is working great except for one silly thing: the print and print preview menus are disabled and do not work with my second document type.

I've looked through all the code and compared with my original document and cannot find any differences or any references to printing or why printing would not work with my second doc type.

Does anybody know what I should do to get the framework automatically handle printing on my second doc type just like it does with my original doc/view type?

Thanks in advance
 
Try manually adding the default printing message maps to your view class (here's an example I did with a RichEditView derived class):

BEGIN_MESSAGE_MAP(CRichTextView, CRichEditView)
//{{AFX_MSG_MAP(CRichTextView)

ON_WM_ERASEBKGND()
ON_WM_CHAR()

//}}AFX_MSG_MAP
// Standard printing commands

ON_COMMAND(ID_FILE_PRINT, CRichEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT,CRichEditView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW,CRichEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

Then you need to override all the OnPreparePrinting(), OnBeginPrinting() etc etc. for your class.

In the OnPreparePrinting() function, you need to add the code I've marked in blue:

BOOL CRichTextView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

Hopefully, you should now have printing capabilities! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top