La Web del Programador: Comunidad de Programadores
https://www.lawebdelprogramador.com/foros/FoxPro-Visual-FoxPro/678005-ver-imagen-de-un-campo-general.html

ver imagen de un campo general

ver imagen de un campo general

Publicado por israel (11 intervenciones) el 19/08/2006 20:12:35
Hola a todos tengo un campo general donde guardo imagenes,, pero no he podido encontrar la forma de como ver la imagen que corresponda a cada registro...

Agradeceria si alguien pudiera echarme la mano con esto...

¿Que objetos puedo utilizar?
¿Que propiedad debo cambiar?
o que debo hacer.

Muchas gracias
sin imagen de perfil

RE:ver imagen de un campo general

Publicado por Ernesto Hernandez (4623 intervenciones) el 19/08/2006 21:45:51
Prueba esto

LOCAL lcDataDIR AS STRING, ;
lcThisDir AS STRING, ;
loRL AS REPORTLISTENER

lcDataDIR = HOME( ) + 'Samples\Tastrade\'
lcThisDir = ADDBS( JUSTPATH( SYS( 16 ) ) )

CD ( lcThisDir )
CLOSE DATA ALL
*-- Create a temp cursor with a few fields, one of which is a
*-- BLOB. Store pictures in this field as raw binary data.
SELECT CAST( ALLTRIM( First_Name ) AS VARCHAR ( 10 ) ) AS 'FNAME', ;
CAST( ALLTRIM( Last_Name ) AS VARCHAR (10 ) ) AS 'LNAME', ;
CAST( FILETOSTR( lcDataDIR + Photo_File ) AS BLOB ) AS 'PIC' ;
FROM ( lcDataDIR + 'data\Employee.dbf' ) ;
INTO CURSOR ReportTemp

*-- Close the table that you selected from. It is not needed.
USE IN SELECT( 'EMPLOYEE' )

*-- 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()

*-- Create an instance of the PreviewListener
*-- class defined later in this code.
*-- Call its custom InitBLOBImage() method,
*-- which creates an instance of an IMAGE object.
*-- This IMAGE has its PictureVal property set to the BLOB
*-- field ( 'ReportTemp.PIC' ) and its reference ( loRL.oBlobImage )
*-- is used as the control source for the OLE Bound control
*-- on the report.
loRL = NEWOBJECT( 'PreviewListener' )
loRL.InitBLOBImage( 'ReportTemp.PIC' )

*-- 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 BlobReport OBJECT loRL
CLOSE DATA ALL
RETURN



*--------------------------------
*-- There has to be some way of redrawing the
*-- picture in the IMAGE class as the record pointer
*-- in the report's driving cursor changes; it does not occur
*-- automatically. This could be done by a UDF() in the PrintWhen
*-- of the OLE Bound control on the report, or as is illustrated here,
*-- by a Report Listener BEFOREBAND() Event.
DEFINE CLASS PreviewListener AS REPORTLISTENER
oBlobImage = NULL
PicBlobFld = ''
LISTENERTYPE = 1 && Preview Listener

PROCEDURE InitBLOBImage(lpcBlobField AS STRING)
THIS.PicBlobFld = lpcBlobField
THIS.oBlobImage = NEWOBJECT( 'IMAGE' )
THIS.oBlobImage.PICTUREVAL = THIS.PicBlobFld
ENDPROC

PROCEDURE BEFOREBAND( nBandObjCode, nFRXRecNo )
*-- Before the DETAIL band is rendered, ;
*-- just redraw the IMAGE object so that it has
*-- the correct picture from the BLOB field.
IF nBandObjCode = 4 && Detail band
THIS.oBlobImage.PICTUREVAL =;
EVALUATE( THIS.PicBlobFld )
ENDIF
ENDPROC
ENDDEFINE


*--------------------------------
*-- 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 BlobReport FROM ReportTemp

*-- Open the report file (FRX) as a table.
USE BlobReport.FRX IN 0 ALIAS TheReport EXCLUSIVE
SELECT TheReport

*-- Increase the height of the Detail band
*-- (ObjType = 9 & ObjCode = 4) to fit the
*-- Picture/OLE Bound control that is inserted later.
UPDATE TheReport SET Vpos = 0, Hpos = 0, HEIGHT = 23542;
WHERE ObjType = 9 AND ObjCode = 4

*-- Since you increased the height of the Detail Band, you need to move
*-- the items from the footer down so they are back in the footer again.
UPDATE TheReport SET Vpos = 29479.167 ;
WHERE ( ObjType = 8 OR ObjType = 5 ) AND ;
INLIST( EXPR, 'DATE()', '"Page "', '_PAGENO' )

*-- 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', 'loRL.oBlobImage' ) && The object ref to the IMAGE object.
ADDPROPERTY( loNewRecObj, 'Hpos', 27500.000) && Place it in DETAIL band.
ADDPROPERTY( loNewRecObj, 'Vpos', 3854.167)
ADDPROPERTY( loNewRecObj, 'HEIGHT', 21354.167)
ADDPROPERTY( loNewRecObj, 'WIDTH', 25104.167)
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


Suerte

RE:ver imagen de un campo general

Publicado por Plinio (7841 intervenciones) el 20/08/2006 01:16:40
Puedes tener un objecto IMAGE y en la propiedad controlsource hacer referencia al campo general de la tabla.

RE:ver imagen de un campo general

Publicado por carlos alfonso (9 intervenciones) el 29/08/2006 03:21:26
no te complique chequea elejemplo de tastrade del solution del vfp en el lomanejan como campos memos
chao
suert