zoukankan      html  css  js  c++  java
  • MFC获取纸张大小

    BOOL CPrintView::GetPageSize(CSize &nRetVal)  // CPrintView 是自己创建的类
          {
             PRINTDLG FAR * pPrintDlg = new PRINTDLG;
             BOOL bRet = FALSE;
     
          // Get the current printer's settings.
     
             if(AfxGetApp()->GetPrinterDeviceDefaults(pPrintDlg))
             {
     
          // Get pointers to the two setting structures.
     
                DEVNAMES FAR *lpDevNames =
                (DEVNAMES FAR *)::GlobalLock(pPrintDlg->hDevNames);
     
                DEVMODE FAR *lpDevMode =
                (DEVMODE FAR *)::GlobalLock(pPrintDlg->hDevMode);
     
          // Get the specific driver information.
     
                CString szDriver((LPTSTR)lpDevNames +
                                     lpDevNames->wDriverOffset);
                CString szDevice((LPTSTR)lpDevNames +
                                     lpDevNames->wDeviceOffset);
                CString szOutput((LPTSTR)lpDevNames +
                                     lpDevNames->wOutputOffset);
     
          // Create a CDC object according to the current settings.
     
                CDC pDC;
                pDC.CreateDC(szDriver, szDevice, szOutput, lpDevMode);
     
          // Query this CDC object for the width and height of the current
          // page.
     
                /*static int*/ nRetVal.cx = pDC.GetDeviceCaps(HORZSIZE);
               /* static int*/ nRetVal.cy = pDC.GetDeviceCaps(VERTSIZE);
     
          // Get rid of the CDC object.
     
                pDC.DeleteDC();
     
          // Unlock the pointers to the setting structures.
     
                ::GlobalUnlock(pPrintDlg->hDevNames);
                ::GlobalUnlock(pPrintDlg->hDevMode);
     
              bRet = TRUE;
             }
           delete pPrintDlg;
           return bRet;
       }
  • 相关阅读:
    BZOJ1057:[ZJOI2007]棋盘制作——题解
    洛谷4147:玉蟾宫——题解
    洛谷1578:[WC2002]奶牛浴场——题解
    BZOJ1926:[SDOI2010]粟粟的书架——题解
    BZOJ3123:[SDOI2013]森林——题解
    BZOJ1834:[ZJOI2010]网络扩容——题解
    BZOJ2668:[CQOI2012]交换棋子——题解
    BZOJ1070:[SCOI2007]修车——题解
    BZOJ1877:[SDOI2009]晨跑——题解
    在阿里,我们如何管理测试环境
  • 原文地址:https://www.cnblogs.com/liangxiaofeng/p/5713605.html
Copyright © 2011-2022 走看看