Printing in MFC - newbie question

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I'm developing an MDI application in MFC in which I have two different
types of child windows. Both refer to the same Document, but have
different Frames and Views. One of them is the first or main ChildView
that the Wizard sets up, the second I added by copying the
CMultiDocTemplate code process.
So far I am able to draw into both windows in the way that I
desire, but I can only print the contents of the main Child window. I
have tried adding the overrides for all the Printing setup procedures
to the second ChildView without success. When the secondary window is
active and I select Print or PrintPreview from the menu, nothing
happens. Somehow I have to make a link which connects the printing
process to my second child window, but I can't find any info on how to
do this. None of the Sample code that I have seen addresses this
particular situation.
Any suggestions would be appreciated. Thanks, Jim
 
you can handle printing messages in CMainFrame,
the CMainFrame the call GetActiveView()->DoPrinting(...) // create an
interface exporting method DoPrinting

interface IPrintView
{
public:
virtual void DoPrinting()=0;
}

class CView1 :public CView, public IPrintView
{
public:
void DoPrinting(); // implement it

}

class CView2 :public CView, public IPrintView
{
public:
void DoPrinting(); // implement it

}

in CMainFrame printing handler:

if(GetActiveView())
{
IPrintView* pPrint = (IPrintView*)GetActiveView();
pPrint->DoPrint();
}
 
Back
Top