چاپ تصویر
LPARAMETERS tcImage
*tcImage = GETPICT()
*--------------------------------------------------------
* VFP code that shows how to print image files.
* Code adapted from Microsoft Knowledge Base article
* 895602. http://support.microsoft.com/kb/895602/EN-US/
*
* Most of the codes and comments below come from
* Trevor Hancock, from MS
*--------------------------------------------------------
LOCAL lnArea
lnArea = SELECT()
CREATE CURSOR ReportTemp (ImageFile c(150))
INSERT INTO ReportTemp VALUES (tcImage)
*-- This calls a function that makes a report programmatically.
*-- This is included here just to make sure that this sample can be run
*-- as-is, without asking the developer to manually create a report.
MakeReport()
*-- Make sure that the cursor is selected,
*-- and then run the report to preview using
*-- the instance of our Report Listener.
SELECT ReportTemp
REPORT FORM ___ImageReport PREVIEW
DELETE FILE "___ImageReport.fr*"
SELECT (lnArea)
RETURN
*--------------------------------
*-- This function programmatically creates a report
*-- with an OLE Bound control and other fields. This is included
*-- only for demonstration purposes so this article code can stand-alone.
*-- Typically, you would create your own report manually by using
*-- the report designer.
FUNCTION MakeReport
CREATE REPORT ___ImageReport FROM ReportTemp
*-- Open the report file (FRX) as a table.
USE ___ImageReport.FRX IN 0 ALIAS TheReport EXCLUSIVE
SELECT TheReport
*-- Remove from the FRX the auto generated fields and labels
DELETE FROM TheReport WHERE ObjType = 5 AND ObjCode = 0 && Remove the Labels
DELETE FROM TheReport WHERE ObjType = 8 AND ObjCode = 0 && Remove the Fields
*-- Add a Picture/OLE Bound control to the report by inserting a
*-- record with appropriate values. Using an object that is based on the EMPTY
*-- class here and the GATHER NAME class later to insert the record makes it easier to
*-- see which values line up to which fields (when compared to a large
*-- SQL-INSERT command).
LOCAL loNewRecObj AS EMPTY
loNewRecObj = NEWOBJECT( 'EMPTY' )
ADDPROPERTY( loNewRecObj, 'PLATFORM', 'WINDOWS' )
ADDPROPERTY( loNewRecObj, 'Uniqueid', SYS(2015) )
ADDPROPERTY( loNewRecObj, 'ObjType', 17 ) && "Picture/OLE Bound Control"
ADDPROPERTY( loNewRecObj, 'NAME', 'ReportTemp.ImageFile' ) && The object ref to the IMAGE object.
ADDPROPERTY( loNewRecObj, 'Hpos', 100)
ADDPROPERTY( loNewRecObj, 'Vpos', 600)
ADDPROPERTY( loNewRecObj, 'HEIGHT', 100000)
ADDPROPERTY( loNewRecObj, 'WIDTH', 100000)
ADDPROPERTY( loNewRecObj, 'DOUBLE', .T. ) && Picture is centered in the "Picture/OLE Bound Control"
ADDPROPERTY( loNewRecObj, 'Supalways', .T. )
*-- For the Picture/OLE Bound control, the contents of the OFFSET field specify whether
*-- Filename (0), General field name (1), or Expression (2) is the source.
ADDPROPERTY( loNewRecObj, 'Offset', 2 )
*-- Add the Picture/OLE Bound control record to the report.
APPEND BLANK IN TheReport
GATHER NAME loNewRecObj MEMO
*-- Clean up and then close the report table.
PACK MEMO
USE IN SELECT( 'TheReport' )
ENDFUNC