Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / QPrinterInfo.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================
' Type Objet
' Classe QPrinterInfo version 1.0
'=======================================================
     CONST PI_HORZSIZE=4           '  Horizontal size in millimeters
     CONST PI_VERTSIZE=6           '  Vertical size in millimeters
     CONST PI_HORZRES=8            '  Horizontal width in pixels
     CONST PI_VERTRES=10           '  Vertical width in pixels
     CONST PI_LOGPIXELSX=88        '  Logical pixels/inch in X
     CONST PI_LOGPIXELSY=90        '  Logical pixels/inch in Y
     CONST PI_PHYSICALWIDTH=110 '  Physical Width in device units
     CONST PI_PHYSICALHEIGHT=111 '  Physical Height in device units
     CONST PI_PHYSICALOFFSETX=112 '  Physical Printable Area x margin
     CONST PI_PHYSICALOFFSETY=113 '  Physical Printable Area y margin

     DECLARE FUNCTION PiGetDeviceCaps LIB "gdi32" ALIAS "GetDeviceCaps" (hdc AS LONG,nIndex AS LONG) AS LONG
     DECLARE FUNCTION PiGetDC LIB "user32" ALIAS "GetDC" (BYVAL hwnd AS LONG) AS LONG
     DECLARE FUNCTION PiReleaseDC LIB "user32" ALIAS "ReleaseDC" (BYVAL hwnd AS LONG, BYVAL hdc AS LONG) AS LONG
     DECLARE FUNCTION PiGetDesktopWindow LIB "user32.dll" ALIAS "GetDesktopWindow" () AS LONG

     TYPE QPrinterInfo EXTENDS QOBJECT

  '============================
  ' return scale printer
  '============================
      FUNCTION Scale() AS DOUBLE
       DIM dc AS LONG

       dc=PiGetDC(PiGetDesktopWindow())
       result=PiGetDeviceCaps(printer.handle,PI_LOGPIXELSX)/PiGetDeviceCaps(dc,PI_LOGPIXELSX)
       PiReleaseDC(PiGetDesktopWindow(),dc)
      END FUNCTION

  '=====================================
  'return dpi printer(points per inch)
  '=====================================
      FUNCTION Dpi() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_LOGPIXELSX)
      END FUNCTION

  '=========================================
  'return ppm printer(pixel per millimeter)
  '=========================================
      FUNCTION Ppm() AS DOUBLE
       result=PiGetDeviceCaps(printer.handle,PI_HORZRES)/PiGetDeviceCaps(printer.handle,PI_HORZSIZE)
      END FUNCTION

  '=========================================
  'return convert millimeter to pixel
  '=========================================
      FUNCTION MetricToPixel(mm AS DOUBLE) AS INTEGER
       result=ROUND(QPrinterInfo.Ppm()*mm)
      END FUNCTION

  '=========================================
  'return convert pixel to millimeter
  '=========================================
      FUNCTION PixelToMetric(pixel AS INTEGER) AS DOUBLE
       result=pixel/QPrinterInfo.Ppm()
      END FUNCTION

  '=========================================
  'return horz page size in millimeter
  '=========================================
      FUNCTION HorzPageSize() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_HORZSIZE)
      END FUNCTION

  '=========================================
  'return vert page size in millimeter
  '=========================================
      FUNCTION VertPageSize() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_VERTSIZE)
      END FUNCTION

  '=========================================
  'return page width in pixel
  '=========================================
      FUNCTION PageWidth() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_HORZRES)
      END FUNCTION

  '=========================================
  'return page height in pixel
  '=========================================
      FUNCTION PageHeight() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_VERTRES)
      END FUNCTION

  '=========================================
  'return physical page width in pixel
  '=========================================
      FUNCTION PhWidth() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_PHYSICALWIDTH)
      END FUNCTION

  '=========================================
  'return physical page height in pixel
  '=========================================
      FUNCTION PhHeight() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_PHYSICALHEIGHT)
      END FUNCTION

  '=========================================
  'return physical page horz in millimeter
  '=========================================
      FUNCTION PhHorz() AS INTEGER
       DIM pixel AS INTEGER

       pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALWIDTH)
       result=ROUND(pixel/QPrinterInfo.Ppm())
      END FUNCTION

  '=========================================
  'return physical page vert in millimeter
  '=========================================
      FUNCTION PhVert() AS INTEGER
       DIM pixel AS INTEGER

       pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALHEIGHT)
       result=ROUND(pixel/QPrinterInfo.Ppm())
      END FUNCTION

  '=========================================
  'return physical margin x in millimeter
  '=========================================
      FUNCTION PhMarginX() AS DOUBLE
       DIM pixel AS INTEGER

       pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETX)
       result=pixel/QPrinterInfo.Ppm()
      END FUNCTION

  '=========================================
  'return physical margin y in millimeter
  '=========================================
      FUNCTION PhMarginY() AS DOUBLE
       DIM pixel AS INTEGER

       pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETY)
       result=pixel/QPrinterInfo.Ppm()
      END FUNCTION

  '=========================================
  'return physical margin x in pixel
  '=========================================
      FUNCTION PhLeftMargin() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETX)
      END FUNCTION

  '=========================================
  'return physical margin y in pixel
  '=========================================
      FUNCTION PhTopMargin() AS INTEGER
       result=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETY)
      END FUNCTION
     END TYPE
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-02-27 08:45:46