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

x
?
Solved

How to print multiple copies?

Posted on 1998-10-05
4
Medium Priority
?
250 Views
Last Modified: 2013-11-20
I'm using the GetDefaultDC (I think that's what it's called)... How do I print multiple copies of the document like this w/o displaying the printer dialog box. I set the number of pages var in the structure to the correct number of copies, but it always just prints one copy. Thanks.
0
Comment
Question by:maknight
[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
  • 2
4 Comments
 
LVL 3

Expert Comment

by:plaroche
ID: 1322929
Can you paste some code of what you're doing? Are you doing this in the doc/view architecture?  Just give us more details and we'll do our best.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1322930
1. You can test if your printer supports multiple copies using DeviceCapabilities.  [not all printers do]

2. You can set the number of copies for a Printer using the DocumentProperties API call

3. I don't think you mean GetDefaultDC
0
 

Author Comment

by:maknight
ID: 1322931
Here is some sample code of the section in question... Would DocumentProperties work with this method?

      // create the print object (display print dlg set, print all pages w/o page numbers, hide print to file, disable selection)
      CPrintDialog *PrintTheReportDlg = new CPrintDialog(FALSE,PD_ALLPAGES | PD_COLLATE | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION | PD_RETURNDC);
      PrintTheReportDlg->m_pd.nCopies = numberofcopies;

      // display the Print Dialog where user can select their preferred settings if Print button was pressed
      if (showprintdlg)
            {
            int return_value = PrintTheReportDlg->DoModal();
            // if dialog did not return IDOK, then check for an error occurance
            if (return_value != IDOK)
                  {
                  if (return_value != IDCANCEL)
                        AfxMessageBox("The Printer Dialog Returned An Error.\nCannot Print Report.",MB_OK | MB_ICONEXCLAMATION);
                  delete PrintTheReportDlg;
                  return(FALSE);
                  }
            }
      // on AutoPrint, we just call for the default printer info
      else
            PrintTheReportDlg->GetDefaults();

0
 
LVL 3

Expert Comment

by:plaroche
ID: 1322932
Here's the doc for nCopies in the PRINTDLG structure:

nCopies
Contains the initial number of copies for the Copies edit control if hDevMode is NULL; otherwise, the dmCopies member of the DEVMODE structure contains the initial value. When PrintDlg returns, nCopies contains the actual number of copies to print. This value depends on whether the application or the printer driver is responsible for printing multiple copies. If the PD_USEDEVMODECOPIESANDCOLLATE flag is set in the Flags member, nCopies is always 1 on return, and the printer driver is responsible for printing multiple copies. If the flag is not set, the application is responsible for printing the number of copies specified by nCopies. For more information, see the description of the PD_USEDEVMODECOPIESANDCOLLATE flag.


As you can see sometimes the printer will be responsible for the copies and sometimes the APP will be responsible.  This means that your printer might not be able to handle mutliple copies. Check for the flag as explained up here and either print the copies yourself by placing your code in a for() statement or not, depending on the presence of the flag.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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

604 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