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;
       }
  • 相关阅读:
    smarty通过asssign传入的值不能在模板显示值
    如何选择合适的MySQL存储引擎
    列表 li 中的文字无法垂直居中
    php 中在 CCS文件中设置背景图片无效:
    完美实现个人建站梦想 全面了解IIS组建方法
    颂孔明
    <青春飞扬>诗集出版的历史价值
    市场部常用名词(培训资料整理)
    爱的脚步
    一位闯荡江湖多年的商人的感悟
  • 原文地址:https://www.cnblogs.com/liangxiaofeng/p/5713605.html
Copyright © 2011-2022 走看看