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

x
?
Solved

Setting Orientation using CPageSetupDialog  class

Posted on 2003-10-21
6
Medium Priority
?
594 Views
Last Modified: 2013-11-20
How can we set Orientation(Landscape or Portrait) using CPageSetupDialog.
How can we know which orientation is actually been selected.
0
Comment
Question by:kalyanreddy_kk
[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
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 200 total points
ID: 9590372
See the sample code in MSDN topic CWinApp::GetPrinterDeviceDefaults.

    http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_cwinapp.3a3a.getprinterdevicedefaults.asp
    {{ link added -- DR / EE PE }}
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9591189
>> How can we set Orientation(Landscape or Portrait) using CPageSetupDialog.

After construction, you can access the m_psd member variable. Allocate a DEVMODE structure with GlobalAlloc(), set the fields properly (it seems you're interested in dmOrientation only, but I think you'll have to fill the rest as well), put the handle in m_psd.hDevMode and call DoModal(). Remember to free that memory when you're done.

>> How can we know which orientation is actually been selected.

After DoModal(), call GetDevMode(), read the dmOrientation field (don't forget to call GlobalUnlock() on the returned pointer)

0
 

Expert Comment

by:ViralPurohit
ID: 9601275
Code Snippet from my application, Hope this helps

BOOL CMyApp::SetPrinterOrientation(BOOL bLandscape)
{
  if (!m_hDevMode) return FALSE;

  DEVMODE *pstDevMode = (DEVMODE *)GlobalLock(m_hDevMode);

  pstDevMode->dmFields |= DM_ORIENTATION;

  pstDevMode->dmOrientation = bLandscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT;

  GlobalUnlock(m_hDevMode);

  return TRUE;
}


/// Or you can use this function
/// param can be DMORIENT_LANDSCAPE
void CMyApp::SetPrinterOrientation(int nOri)
{
      PRINTDLG   pd;
      
      pd.lStructSize = (DWORD) sizeof(PRINTDLG);
      if (GetPrinterDeviceDefaults(&pd)){
            DEVMODE FAR* pDevMode = (DEVMODE FAR*)::GlobalLock(m_hDevMode);
             
            if (pDevMode){
                  pDevMode->dmOrientation = nOri;
                  
                  ::GlobalUnlock(m_hDevNames);
                  ::GlobalUnlock(m_hDevMode);
            }
      }
}


Regards,
Viral Purohit
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 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