change printer settings - Programmer

This is a discussion on change printer settings - Programmer ; Is it really that hard to write a decent application that is able to print (using Microsoft Visual C++ 6) ?! In my CMainFrame class, I added a member to manage the page setup for the whole application. -------------------------------------------------------------------------------- PAGESETUPDLG* ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: change printer settings

  1. change printer settings

    Is it really that hard to write a decent application that is able to
    print (using Microsoft Visual C++ 6) ?!

    In my CMainFrame class, I added a member to manage the page setup for
    the whole application.

    --------------------------------------------------------------------------------

    PAGESETUPDLG* m_pPageSetupDLG;
    --------------------------------------------------------------------------------



    I also customized the page setup dialog box, so when I press the
    'Printer' button, a call is made to CMyPrintDialog (a class that was
    derived from CPrintDialog).

    --------------------------------------------------------------------------------

    CMainFrame* pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
    CMyPrintDialog dlg(FALSE);
    dlg.m_pd.hDevMode = pMainFrm->m_pPageSetupDLG->hDevMode;
    dlg.m_pd.hDevNames = pMainFrm->m_pPageSetupDLG->hDevNames;
    if (dlg.DoModal() == IDOK)
    {
    DEVMODE* lpDev = (DEVMODE*)::GlobalLock(dlg.m_pd.hDevMode);
    pMainFrm->m_pPageSetupDLG->hDevMode = dlg.m_pd.hDevMode;
    pMainFrm->m_pPageSetupDLG->hDevNames = dlg.m_pd.hDevNames;
    ::GlobalUnlock(dlg.m_pd.hDevMode);
    }
    --------------------------------------------------------------------------------

    In that derived class CMyPrintDialog, I can make some changes to
    m_pd.hDevMode (e.g. dmOrientation, dmScale, dmCopies, ...).
    But the problem is that those adaptions are never shown in the printer
    tabs !
    I tried 'UpdateData(FALSE)', but that doesn't seem do work.

    So ... my first question is : if I change some values in the
    m_pd.hDevMode member of the CPrintDialog class, how can I make them to
    be reflected in the displayed printer tabs ?

    Then ... second question.

    --------------------------------------------------------------------------------

    void CMyPrintDialog::OnOK()
    {
    MessageBeep(0);
    CPrintDialog::OnOK();
    MessageBeep(0);
    }
    --------------------------------------------------------------------------------

    Before executing 'CPrintDialog::OnOK()', the values in 'm_pd.hDevMode'
    are still the ones I changed. After executing 'OnOK', it seems to me
    that the values are updated with the values from the printer tabs. And
    since I didn't manage to update the tabs with new values after I did
    change one of the 'm_pd.hDevMode' parameters, those are not the right
    values !

    So ... when I return from DoModal(), my member of the CMainFrame class
    get the wrong values.

    Anyone any idea how to solve this problem ?
    It would help me a lot.

    Thanks.


  2. Re: change printer settings

    Peter,

    Yes, it is really that hard. "Notoriously tricky" is also a phrase that
    comes to mind :-)))

    Both

    http://www.codeproject.com/printing/

    and

    http://www.codeguru.com/printing/index.shtml

    contains articles and code for this, however.

    Johan Rosengren
    Abstrakt Mekanik AB

    "Peter Simons" a écrit dans le message de
    news:4017AB30.200B6B1B@tst.com...
    > Is it really that hard to write a decent application that is able to
    > print (using Microsoft Visual C++ 6) ?!
    >
    > In my CMainFrame class, I added a member to manage the page setup for
    > the whole application.
    >
    > --------------------------------------------------------------------------

    ------
    >
    > PAGESETUPDLG* m_pPageSetupDLG;
    > --------------------------------------------------------------------------

    ------
    >
    >
    >
    > I also customized the page setup dialog box, so when I press the
    > 'Printer' button, a call is made to CMyPrintDialog (a class that was
    > derived from CPrintDialog).
    >
    > --------------------------------------------------------------------------

    ------
    >
    > CMainFrame* pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
    > CMyPrintDialog dlg(FALSE);
    > dlg.m_pd.hDevMode = pMainFrm->m_pPageSetupDLG->hDevMode;
    > dlg.m_pd.hDevNames = pMainFrm->m_pPageSetupDLG->hDevNames;
    > if (dlg.DoModal() == IDOK)
    > {
    > DEVMODE* lpDev = (DEVMODE*)::GlobalLock(dlg.m_pd.hDevMode);
    > pMainFrm->m_pPageSetupDLG->hDevMode = dlg.m_pd.hDevMode;
    > pMainFrm->m_pPageSetupDLG->hDevNames = dlg.m_pd.hDevNames;
    > ::GlobalUnlock(dlg.m_pd.hDevMode);
    > }
    > --------------------------------------------------------------------------

    ------
    >
    > In that derived class CMyPrintDialog, I can make some changes to
    > m_pd.hDevMode (e.g. dmOrientation, dmScale, dmCopies, ...).
    > But the problem is that those adaptions are never shown in the printer
    > tabs !
    > I tried 'UpdateData(FALSE)', but that doesn't seem do work.
    >
    > So ... my first question is : if I change some values in the
    > m_pd.hDevMode member of the CPrintDialog class, how can I make them to
    > be reflected in the displayed printer tabs ?
    >
    > Then ... second question.
    >
    > --------------------------------------------------------------------------

    ------
    >
    > void CMyPrintDialog::OnOK()
    > {
    > MessageBeep(0);
    > CPrintDialog::OnOK();
    > MessageBeep(0);
    > }
    > --------------------------------------------------------------------------

    ------
    >
    > Before executing 'CPrintDialog::OnOK()', the values in 'm_pd.hDevMode'
    > are still the ones I changed. After executing 'OnOK', it seems to me
    > that the values are updated with the values from the printer tabs. And
    > since I didn't manage to update the tabs with new values after I did
    > change one of the 'm_pd.hDevMode' parameters, those are not the right
    > values !
    >
    > So ... when I return from DoModal(), my member of the CMainFrame class
    > get the wrong values.
    >
    > Anyone any idea how to solve this problem ?
    > It would help me a lot.
    >
    > Thanks.
    >




+ Reply to Thread