Link to home
Start Free TrialLog in
Avatar of ADITYA RAO
ADITYA RAOFlag for India

asked on

OnPrint Does not get called from CFormView

I am working on MDI Application which has all views as CFormView Derived.
On one of view there is graph displayed which needs to be printed.
I overridden all necessary functions like OnBeginPrinting,OnPrint etc.
But these functions did not get called.Please Help
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

This might give you a hint (it appears when you create the project):
User generated image

If you want the MFC printing support do not use CFormView based classes.
ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ADITYA RAO

ASKER

Thank you very much it worked
you are welcome.

No printing support will be available by CFormView

the meaning of the statement is that CFormView itself neither enables printing by an override of OnPreparePrinting nor has an implementation for the other printing member functions which would bring the formview's layout and data to paper.

Sara
And the final sentance was:
If you want the MFC printing support do not use CFormView based classes.


A rough translation of the no print support is that you have to code it all yourself wheras most other CView based classes can use the same code for display to screen or print to paper.
MFC (VS2010) supports printing for

- CEditView
- CHTMLEditView
- COleDocObjectItem

the ColeDocObjectItem is for active-x data. the printing support is only an interface to "callback" functions of the active-x (which you have to provide).

the edit view is not more than an edit field "pushed" to a view and print support only would print plain text.

the html edit view uses the print function of the web browser.

if you enable printing by overriding OnPreparePrinting the implementation  of the CView::OnPrint would call the OnDraw function of your view class virtually (passing a device context for the printing device) such that all drawing you made for the screen also would be made for the printer (see comment of Andy Ainscow). that doesn't work for form views cause the controls would draw themselves rather than been drawn by the parent formview.

in summary, mfc supports only a framework for printing.

Sara