Artículo publicado en la revista FoxPress en julio-agosto de 2006. Algunos datos, versiones y funciones citados (MySQL, PHP, Visual FoxPro, Windows) pueden haber quedado desfasados.
Fuente publicado en el MS Q241424
Por defecto cuando un report es pre-visualizado en Visual FoxPro 9.0, los usuarios pueden imprimir el informe desde el Report Preview mediante uno de los siguientes métodos:
- En el Report Preview toolbar, click el botón de imprimir Print.
- Haciendo click con el botón derecho del ratón en el propio Report y escoger imprimir
En alguna ocasión a uno le podría interesar desactivar esta opción. En versiones anteriores de Visual FoxPro, el archivo de Recursos (foxuser.dbf) se podía cambiar. Más información sobre esto se puede ver en el documento MS
317466 (http://www.kbAlertz.com/Feedback.aspx?kbNumber=317466/) que comenta la forma de quitar los botones del Print Preview toolbar
En Visual FoxPro 9.0, puedes cambiar el archivo FoxUser.dbf para desactivar la ventana Report Preview. Sin embargo, con la introducción de Object-Assisted Reporting, se abre ahora un camino alternativo. Por defecto, Object-Assisted Reporting en Visual FoxPro 9.0 no está activo. Para activarlo puedes cambiar los parámetros de REPORTBEHAVIOR. Para hacer esto usa uno de los siguiente métodos:
Método 1
Cambia el comportamiento del Report Engine mediante el IDE de Visual FoxPro:
- En la opción del menú Tools, click en Options.
- En la ventana de dialogo de Options, click la pestaña Reports, y selecciona 90 (Object Assisted) en el Report Engine behavior.
- (Opcional) si quieres que persista esta configuración entre las sesiones de Visual FoxPro 9.0, click Set As Default en la ventana de dialogo de Options.
Método 2
Ejecuta la siguiente instrucción por código para activar el Object-Assisted Reporting: SET REPORTBEHAVIOR 90
*----------- START CODE
*
*-----------------------------------
* AUTHOR: Trevor Hancock
* CREATED: 02/24/05 02:47:08 PM
* ABSTRACT:
* Shows how to disable printing from
* PREVIEW when you use object-assisted
* reporting in VFP9.
*
* Also includes a workaround for problem
* where the PREVIEW toolbar does not
* recognize the TextOnToolbar or
* PrintFromPreview settings between
* toolbar displays during same preview.
*-----------------------------------
*-- Defines whether to alllow for
*-- printing during preview. Used to set
*-- the "AllowPrintfromPreview" property
*-- of the object-assisted preview container
*-- later in this code.
#DEFINE PrintFromPreview .F.
LOCAL loPreviewContainer AS FORM, ;
loReportListener AS REPORTLISTENER, ;
loExHandler AS ExtensionHandler OF SYS(16)
*-- Get a preview container from the
*-- .APP registered to handle object-assisted
*-- report previewing.
loPreviewContainer = NULL
DO (_REPORTPREVIEW) WITH loPreviewContainer
*-- Create a PREVIEW listener
loReportListener = NEWOBJECT('ReportListener')
loReportListener.LISTENERTYPE = 1 &&Preview
*-- Link the Listener and preview container
loReportListener.PREVIEWCONTAINER = loPreviewContainer
*-- Changing this property prevents printing from the Preview toolbar
*-- and from right-clicking on the preview container, and then clicking "print".
*-- This property is not in the VFP9 documentation at this point.
loPreviewContainer.AllowPrintfromPreview = PrintFromPreview
*-- Controls appearance of text on some of the
*-- Preview toolbar buttons. .F. is the default.
*-- Included here just to show that it is an available option.
loPreviewContainer.TextOnToolbar = .F.
*-- Create an extension handler and hook it to the
*-- preview container. This will let you manipulate
*-- properties of the container and its Preview toolbar
loExHandler = NEWOBJECT('ExtensionHandler')
loPreviewContainer.SetExtensionHandler( loExHandler )
REPORT FORM ;
HOME() + 'Samples\Solution\Reports\colors.frx' ;
OBJECT loReportListener
RELEASE loPreviewContainer, loReportListener, loExHandler
*-------------------------
*-------------------------
DEFINE CLASS ExtensionHandler AS CUSTOM
*-- Ref to the Preview Container's Preview Form
PreviewForm = NULL
*-- Here you implement (hook into) the PreviewForm_Assign
*-- event of the preview container's parent proxy
PROCEDURE PreviewForm_Assign( loRef )
*-- Perform default behavior: assign obj ref.
THIS.PreviewForm = loRef
*-- Grab the obj ref to the preview form and bind to its
*-- ShowToolbar() method. This lets the
*-- STB_Handler() method of this extension handler
*-- to run code whenever the Preview toolbar is shown
*-- by the PreviewForm.ShowToolbar() method.
IF !ISNULL( loRef )
BINDEVENT(THIS.PreviewForm, ;
'ShowToolbar', THIS, 'STB_Handler')
ENDIF
ENDPROC
PROCEDURE STB_Handler(lEnabled)
*-- Here you work around the setting
*-- persistence problem in the Preview toolbar.
*-- The Preview toolbar class (frxpreviewtoolbar)
*-- already has code that you can use to enforce
*-- setting's persistence; it is just not called. Here,
*-- you call it.
WITH THIS.PreviewForm.TOOLBAR
.REFRESH()
*-- When you call frxpreviewtoolbar::REFRESH(), the
*-- toolbar caption is set to its Preview form,
*-- which differs from typical behavior. You must revert that
*-- to be consistent. If you did not do this,
*-- you would see " - Page 2" appended to the toolbar
*-- caption if you skipped pages.
.CAPTION = THIS.PreviewForm.formCaption
ENDWITH
ENDPROC
*-- A preview container requires these methods
*-- to be implemented in an associated preview extension handler.
*-- They are not used in this example, but still must be here.
PROCEDURE AddBarsToMenu( cPopup, iNextBar )
PROCEDURE SHOW( iStyle )
ENDPROC
PROCEDURE HandledKeyPress( nKeyCode, nShiftAltCtrl )
RETURN .F.
ENDPROC
PROCEDURE PAINT
ENDPROC
PROCEDURE RELEASE
RETURN .T.
ENDPROC
*
¿Quieres llevar la IA a los datos de tu empresa?
En una auditoría gratuita de 30 minutos vemos qué caso concreto te ahorraría más trabajo.
Reservar mi auditoría →