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;
       }
  • 相关阅读:
    js高级程序设计AJAX && JSON
    python核心高级学习总结7正则表达式
    python核心高级学习总结8动态性、__slots__、生成器、迭代器、装饰、闭包
    python核心高级学习总结3python实现进程的三种方式及其区别
    python核心高级学习总结6面向对象进阶之元类
    运维术语名词
    资源分享编程、数据库、安全、运维等
    python之Bug之字符串拼接bug
    CSS hack:实现IE6、IE7、Firefox兼容(转摘)
    (装载) Web开发技术的历史发展简介
  • 原文地址:https://www.cnblogs.com/liangxiaofeng/p/5713605.html
Copyright © 2011-2022 走看看