• 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;
       }
  • 相关阅读:
    python 基础第二篇
    python 基础第五篇
    python 基础第四篇
    购物小编程(完整编码)
    计算机 python概论
    str 相关操作
    python 基础第三篇
    Nginx 配置多站点vhost
    h5页面宽度设置7.5rem
    js 倒计时,转义
  • 原文地址:https://www.cnblogs.com/liangxiaofeng/p/5713605.html
Copyright © 2020-2023  润新知