CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: mfc printing

  1. #1
    Join Date
    Aug 2000
    Posts
    18

    mfc printing

    Is there a small block of code I can add to force (or default) to landscape orientation, no matter which network or local printer is selected?

    thanks


  2. #2
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    Re: mfc printing

    It has to be done on a device-by-device basis, so your code needs to monitor all print requests and make the change at runtime. It is handled through the DEVMODE structure, documented in the Platform SDK docs.

    // set landscape mode
    DEVMODE* pDevMode = printDlg.GetDevMode();
    if (pDevMode != NULL)
    {
    pDevMode->dmOrientation = DMORIENT_LANDSCAPE;
    dc.ResetDC(pDevMode);
    GlobalFree(pDevMode);
    }





  3. #3
    Join Date
    Aug 2000
    Posts
    18

    Re: mfc printing

    thanks. Actually, I found out that if you put the following code in the WinApp module, all printers default to landscape. When the print dialog comes up, landscape is pre-checked.

    {
    PRINTDLG pd;
    pd.lStructSize=(DWORD)sizeof(PRINTDLG);
    BOOL bRet=GetPrinterDeviceDefaults(&pd);
    if(bRet)
    {
    // protect memory handle with ::GlobalLock and ::GlobalUnlock
    DEVMODE FAR *pDevMode=(DEVMODE FAR *)::GlobalLock(m_hDevMode);
    // set orientation to landscape
    pDevMode->dmOrientation=DMORIENT_LANDSCAPE;
    ::GlobalUnlock(m_hDevMode);
    }
    }



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