CONST PI_HORZSIZE=4
CONST PI_VERTSIZE=6
CONST PI_HORZRES=8
CONST PI_VERTRES=10
CONST PI_LOGPIXELSX=88
CONST PI_LOGPIXELSY=90
CONST PI_PHYSICALWIDTH=110
CONST PI_PHYSICALHEIGHT=111
CONST PI_PHYSICALOFFSETX=112
CONST PI_PHYSICALOFFSETY=113
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
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
FUNCTION Dpi() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_LOGPIXELSX)
END FUNCTION
FUNCTION Ppm() AS DOUBLE
result=PiGetDeviceCaps(printer.handle,PI_HORZRES)/PiGetDeviceCaps(printer.handle,PI_HORZSIZE)
END FUNCTION
FUNCTION MetricToPixel(mm AS DOUBLE) AS INTEGER
result=ROUND(QPrinterInfo.Ppm()*mm)
END FUNCTION
FUNCTION PixelToMetric(pixel AS INTEGER) AS DOUBLE
result=pixel/QPrinterInfo.Ppm()
END FUNCTION
FUNCTION HorzPageSize() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_HORZSIZE)
END FUNCTION
FUNCTION VertPageSize() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_VERTSIZE)
END FUNCTION
FUNCTION PageWidth() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_HORZRES)
END FUNCTION
FUNCTION PageHeight() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_VERTRES)
END FUNCTION
FUNCTION PhWidth() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_PHYSICALWIDTH)
END FUNCTION
FUNCTION PhHeight() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_PHYSICALHEIGHT)
END FUNCTION
FUNCTION PhHorz() AS INTEGER
DIM pixel AS INTEGER
pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALWIDTH)
result=ROUND(pixel/QPrinterInfo.Ppm())
END FUNCTION
FUNCTION PhVert() AS INTEGER
DIM pixel AS INTEGER
pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALHEIGHT)
result=ROUND(pixel/QPrinterInfo.Ppm())
END FUNCTION
FUNCTION PhMarginX() AS DOUBLE
DIM pixel AS INTEGER
pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETX)
result=pixel/QPrinterInfo.Ppm()
END FUNCTION
FUNCTION PhMarginY() AS DOUBLE
DIM pixel AS INTEGER
pixel=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETY)
result=pixel/QPrinterInfo.Ppm()
END FUNCTION
FUNCTION PhLeftMargin() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETX)
END FUNCTION
FUNCTION PhTopMargin() AS INTEGER
result=PiGetDeviceCaps(printer.handle,PI_PHYSICALOFFSETY)
END FUNCTION
END TYPE
|