Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. landscape print in dialog?

landscape print in dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JockeP
    wrote on last edited by
    #1

    Is there a way to change the print page orientation to landscape in a dialog mode, i e I'm not using Document- View mode? To print I've previously used ShellExecute method.

    E 1 Reply Last reply
    0
    • J JockeP

      Is there a way to change the print page orientation to landscape in a dialog mode, i e I'm not using Document- View mode? To print I've previously used ShellExecute method.

      E Offline
      E Offline
      Eugene Pustovoyt
      wrote on last edited by
      #2

      Look this code:

      PRINTDLG pd;
      pd.lStructSize=(DWORD)sizeof(PRINTDLG);
      if(AfxGetApp()->GetPrinterDeviceDefaults(&pd))
      {
      // protect memory handle with ::GlobalLock and ::GlobalUnlock
      DEVMODE FAR *lpDevMode=(DEVMODE FAR *)::GlobalLock(pd.hDevMode);
      lpDevMode->dmOrientation = (short)(bLandscape) ? ORIENT_LANDSCAPE : DMORIENT_PORTRAIT);
      pDC->ResetDC(lpDevMode);
      ::GlobalUnlock(pd.hDevMode);
      }

      Best regards, Eugene Pustovoyt

      J 1 Reply Last reply
      0
      • E Eugene Pustovoyt

        Look this code:

        PRINTDLG pd;
        pd.lStructSize=(DWORD)sizeof(PRINTDLG);
        if(AfxGetApp()->GetPrinterDeviceDefaults(&pd))
        {
        // protect memory handle with ::GlobalLock and ::GlobalUnlock
        DEVMODE FAR *lpDevMode=(DEVMODE FAR *)::GlobalLock(pd.hDevMode);
        lpDevMode->dmOrientation = (short)(bLandscape) ? ORIENT_LANDSCAPE : DMORIENT_PORTRAIT);
        pDC->ResetDC(lpDevMode);
        ::GlobalUnlock(pd.hDevMode);
        }

        Best regards, Eugene Pustovoyt

        J Offline
        J Offline
        JockeP
        wrote on last edited by
        #3

        Thanks, but I get these five errors when compiling: error C2065: 'bLandscape' : undeclared identifier error C2065: 'ORIENT_LANDSCAPE' : undeclared identifier error C2059: syntax error : ')' error C2065: 'pDC' : undeclared identifier error C2227: left of '->ResetDCA' must point to class/struct/union Generating Code... Error executing cl.exe. It seems bLandscape does not exist. Where does that variable come from? I can also not find ORIENT_LANDSCAPE in MSDN.

        E 1 Reply Last reply
        0
        • J JockeP

          Thanks, but I get these five errors when compiling: error C2065: 'bLandscape' : undeclared identifier error C2065: 'ORIENT_LANDSCAPE' : undeclared identifier error C2059: syntax error : ')' error C2065: 'pDC' : undeclared identifier error C2227: left of '->ResetDCA' must point to class/struct/union Generating Code... Error executing cl.exe. It seems bLandscape does not exist. Where does that variable come from? I can also not find ORIENT_LANDSCAPE in MSDN.

          E Offline
          E Offline
          Eugene Pustovoyt
          wrote on last edited by
          #4

          I can't write a code for yours. Just it is a sample of the code and not realy code. bLanscape is a variable which specified what you want orient. TRUE - LANSCAPE, FALSE - PORTRAIT.:( DMORIENT_LANDSCAPE is constant for DEVMODE strucrure. Therefore, you must look in MSDN DEVMODE structure and not constants. pDC is a pointer to your context of the printer. Best regards, Eugene Pustovoyt

          J 1 Reply Last reply
          0
          • E Eugene Pustovoyt

            I can't write a code for yours. Just it is a sample of the code and not realy code. bLanscape is a variable which specified what you want orient. TRUE - LANSCAPE, FALSE - PORTRAIT.:( DMORIENT_LANDSCAPE is constant for DEVMODE strucrure. Therefore, you must look in MSDN DEVMODE structure and not constants. pDC is a pointer to your context of the printer. Best regards, Eugene Pustovoyt

            J Offline
            J Offline
            JockeP
            wrote on last edited by
            #5

            Thanks for your reply Eugene! However, I'm sorry I still dont get it. I'm not using Document-View mode in which I think I know how to retreive the Device Context (pDC). I'm using Dialog mode. How can you acheive this? I also noticed you converted bLandscape to short. Why? Isn't it only the value that's assignmed dmOrientation that needs to be short?! Finally, does this alter the settings of my default printer straight away without showing any dialog, or what happens? Thanks again, Joachim

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups