CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    30

    How to print multiple copies?

    Hi,

    I want to print multiple copies by changing the value of dmCopies in m_pd of CPrintDialog class.
    It works fine for most of the printers, but when I tried it on Canon BJ-200e it always prints out one copy only. Can anyone tell me what's wrong with my program? Thanks in advance.

    //get default print dialog values
    CPrintDialog dlg(FALSE);
    if (dlg.GetDefaults())
    {
    LPDEVMODE lpdm = (LPDEVMODE)GlobalLock (dlg.m_pd.hDevMode);
    char szPrinterDevName[CCHDEVICENAME];
    if (lpdm != NULL)
    {
    //set number of copies to print
    lpdm->dmCopies = m_iNumOfCopy;
    //m_iNumOfCopy is the number of copies to
    //get printer name
    memcpy(szPrinterDevName, lpdm->dmDeviceName, sizeof(lpdm->dmDeviceName));
    CString stPrinterDevName;
    stPrinterDevName = szPrinterDevName;
    DEVMODE *InitData = dlg.GetDevMode();
    m_hDC = CreateDC(NULL, szPrinterDevName, NULL, InitData);
    if (m_hDC == NULL)
    return FALSE;
    GlobalUnlock(dlg.m_pd.hDevMode);
    }


  2. #2
    Join Date
    Mar 2001
    Location
    Albuquerque, NM
    Posts
    12

    Re: How to print multiple copies?

    You wrote
    I want to print multiple copies by changing the value of dmCopies in m_pd of CPrintDialog class.
    It works fine for most of the printers, but when I tried it on Canon BJ-200e it always prints out one copy only. Can anyone tell me what's wrong with my program? Thanks in advance.

    //get default print dialog values
    CPrintDialog dlg(FALSE);
    if (dlg.GetDefaults())
    {
    LPDEVMODE lpdm = (LPDEVMODE)GlobalLock (dlg.m_pd.hDevMode);
    char szPrinterDevName[CCHDEVICENAME];
    if (lpdm != NULL)
    {
    //set number of copies to print
    lpdm->dmCopies = m_iNumOfCopy;
    //m_iNumOfCopy is the number of copies to
    //get printer name
    memcpy(szPrinterDevName, lpdm->dmDeviceName, sizeof(lpdm->dmDeviceName));
    CString stPrinterDevName;
    stPrinterDevName = szPrinterDevName;
    DEVMODE *InitData = dlg.GetDevMode();
    m_hDC = CreateDC(NULL, szPrinterDevName, NULL, InitData);

    if (m_hDC == NULL)
    return FALSE;
    GlobalUnlock(dlg.m_pd.hDevMode);
    }
    }




    Not all printer drivers support multiple copies.
    the code:
    if(lpdm->dmFields & DM_COPIES)


    should tell you if it does or not.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured