Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Custom Print Dialogs

Posted on 2004-08-26
10
Medium Priority
?
612 Views
Last Modified: 2013-11-20
Scenario:
I have an application that manipulates data in a variety of ways (table, graph, contact sheets, ect...).
When the user clicks 'print', the application goes through a set of property pages I made that form a 'report wizard' that, through the users manipulation, will tell the app what to print.  After the report wizard is completed, a custom print dialog is displayed that has a summary sheet based on data from the wizard.

Problem:
The app will open and go through the report wizard, then display the custom print dialog.  But clicking print on the custom print dialog simply closes the dialog and nothing prints.  It does not seem to make it to the OnPrint() override, so I suspect that the custom print dialog simply closes and that is as far as it gets.


// here is the function that is called when the user clicks print.
// this function opens the report wizard, then calls the OnPreparePrinting() function.
void CARmemView::OnFilePrint()
{
      CARmemDoc* pDoc = GetDocument();
      ASSERT_VALID(pDoc);

      CDlgPrintPP dlg("Print");
      dlg.m_pTable = pDoc->m_pDataSheet;

      if(dlg.DoModal() == ID_WIZFINISH)
      {
            CPrintInfo info;

            info.m_pPD = new CDlgPrint3(FALSE);

            info.m_pPD->m_pd.nMinPage = 1;
            info.m_pPD->m_pd.nMaxPage = 0xffff;

            info.m_pPD->m_pd.hInstance = AfxGetInstanceHandle();
            info.m_pPD->m_pd.lpPrintTemplateName = MAKEINTRESOURCE(1538);

            info.m_pPD->m_pd.Flags |= PD_ENABLEPRINTTEMPLATE;


            OnPreparePrinting(&info);
      }
}

Maybe there is something I am not initializing properly in the CPrintInfo structure properly?

Thanks for your help =]
0
Comment
Question by:r2far
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 11906679
There are lot of things that default implementation of OnPrint() function does. You have to read the MFC source code to get an idea.
If you are working with VC6, look at:
C:\Program Files\MICROSOFT VISUAL STUDIO\VC98\MFC\SRC\VIEWPRNT.CPP
0
 
LVL 86

Expert Comment

by:jkr
ID: 11906783
Also check out http://www.codeproject.com/printing/customprintdialog.asp ("An easy way to customise the default Print dialog in an MFC app")
0
 
LVL 4

Author Comment

by:r2far
ID: 11907461
jaime_olivares:
OnFilePrint() is called when the user selects 'file->print'.  OnPrint() is a different function, that is called when a page of the document is to be printed.  Correct me if I am wrong.  If I am missing code that would usually be called when the user clicks 'file->print' then what is it?

jkr:
I have done what you have listed with the exception that instead of in OnPreparePrinting(), the CPrintInfo structure is created and modified in the OnFilePrint() function.  The modifications made to the CPrintInfo structure are the same though.


Thanks for the responses
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11907500
Sorry, it was a typo, really I mean OnFilePrint(), read the source code, search for OnFilePrint() implementation in the file I mentioned and you will notice what are you missing.
0
 
LVL 4

Author Comment

by:r2far
ID: 11909071
jaime_olivares:
Ok, that definetly helps.  I knew I somehow cut-out the entire print loop.

I have copied the code, and made a bunch of modifications to suit my needs.  I have one question about the code however.

The compiler says that afxData is an 'undeclared identifier'.  However I can access it's members.  How do I solve that problem?

if (afxData.bMarked4)
    OnPrepareDC(&dcPrint, &printInfo);


I also had problems with a few other functions, however studied the code and found that I did not need those portions and commented them out.  But I am fairly certain that the part shown above is needed =]

Thanks for your help thus far, I am getting very close to my goal.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11909130
afxData is an internal MFC support structure, you can avoid it and use your own variables. It is not intended that you make an exact copy of OnFilePrint(), just to know what function calls are you missing, so it is correct to delete all what you don't need. So, go ahead.

0
 
LVL 4

Author Comment

by:r2far
ID: 11909528
Ok, thanks jaime_olivares.  I think you've given me enough information to complete my task.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11909556
Thanks, r2far.
BTW. How far are you?
0
 
LVL 4

Author Comment

by:r2far
ID: 11909977
oh... very far... very far indeed...
*r2far looks around suspiciously as he backs out of the room.

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 11909991
Someday you will have to tell....................
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question