Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxyPreviewer Print Tool Bar 1

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
How can replace the Standard Print Tool Bar with FoxyPreviewer Print Tool bar before calling Report Form
 
Isn't that automatically happening?

There should be some readme or howto with foxypreviewer and how to use it. The simplest usage is to DO FOXYPREVIEWER.APP in your exe at startup and then REPORT FORM calls even without using some explicit foxypreviewer reportlistener will go through FoxyPreviewer handling of reports, including the print toolbar at print previews.

You could perhaps manage to start this toolbar without the preview, but it wouldn't help at all, as it needs the context of a preview, it interacts with the preview container window, for example, so don't try to go that route, that idea doesn't work out at all.

If you want to do stuff like printing to PDF without going through the preview and without instructing your users to use the Save tool from the FoxyPreviewer Toolbar, you have lots of options available in _screen.oFoxyPreviewer after DO FOXYPREVIEWER.APP. This enables you to configure the print behavior before printing and without preview.

Also search the web for sample usages.

Bye, Olaf.
 
The way I have achieved this (if in fact it's what you're looking for) is to the put the following at the start of your .prg:

Code:
#DEFINE PrintFromPreview .F.
LOCAL loPreviewContainer AS FORM, ;
  loReportListener AS REPORTLISTENER, ;
  loExHandler AS ExtensionHandler OF SYS(16)

loPreviewContainer = NULL
DO (_REPORTPREVIEW) WITH loPreviewContainer
loReportListener = NEWOBJECT('ReportListener')
loReportListener.LISTENERTYPE = 1 &&Preview
loReportListener.PREVIEWCONTAINER = loPreviewContainer
loPreviewContainer.AllowPrintfromPreview = PrintFromPreview
loPreviewContainer.TextOnToolbar = .F.
loExHandler = NEWOBJECT('ExtensionHandler')
loPreviewContainer.SetExtensionHandler( loExHandler )

Then issue your relevant command:

Code:
REPORT FORM MYFORM PREVIEW NOCONSOLE FOR FIELDNAME="whatever" OBJECT loReportListener

At the end of my .prg have the following:

Code:
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

ENDDEFINE

This is how the foxypreviewer instructions suggested and it works for me.
 
That was perhaps necessary with an early version, but look at this:
The recommended mode - make it simple !!!
from now on, I'm recommending people to use only the simplified mode:
Code:
DO FoxyPreviewer.app
REPORT FORM YourReport PREVIEW

Don't overcomplicate it. You even only need to do the FoxyPreviewer.app once at startup.
If you want to add to the toolbar, foxypreviewer comes with full source code PJX, simply change the toolbar as you like and recompile your own foxypreviewer.app

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top