打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
如何防止列印在報表中預覽 Visual FoxPro 9.0
Microsoft Visual FoxPro 9.0 介紹 Object-Assisted 報告架構。以這種新的設計,您可以直接透過程式碼與互動報表工具,如報表設計師和報表預覽 Visual FoxPro 9.0。因此,很容易就能停用的功能比在舊版的 Visual FoxPro,可以從 Visual FoxPro 9.0 在報表預覽列印。本文說明如何撰寫程式碼直接互動,並設定 Object-Assisted 報告報表預覽。

根據預設,當 Visual FoxPro 9.0 中預覽的物件協助報表使用者可以列印報表從報表預覽視窗使用下列方法之一:
  • 在報表預覽工具列上,按一下 [列印] 按鈕。
  • 報表預覽視窗內部,以滑鼠右鍵按一下,然後按一下 [列印
若要停用此選項。在舊版的 Visual FoxPro,必須變更 Visual FoxPro 資源檔 (FoxUser.dbf)。如需有關如何執行這項操作的詳細資訊,請按一下下面的文件編號,檢視 「 Microsoft 知識庫 」 中的文件:
317466如何從預覽列印] 工具列移除按鈕

在 Visual FoxPro 到 9.0,您仍然可以變更 [停用列印從報表預覽視窗的 FoxUser.dbf 檔案。然而,引入 Object-Assisted 報告之後,替代方法現在可以了。根據預設,未啟用 Object-Assisted 報告 Visual FoxPro 9.0。若要啟用它,您必須將 REPORTBEHAVIOR 設定變更。若要這樣做,請使用下列方法之一:
  • 方法 1
    變更到 Visual FoxPro IDE 報表引擎行為設定:
    1. 按一下 [工具] 功能表上的 [選項
    2. 在 [選項] 對話方塊中,按一下 [報表] 索引標籤,然後選取(物件協助) 的 90報表引擎的方式] 清單。
    3. (選擇性)如果您希望 Visual FoxPro 9.0 工作階段之間保留這個設定,請按一下 [選項] 對話方塊中的 [設成預設值
  • 方法 2
    若要啟用 Object-Assisted 所報告的程式碼中,執行下列命令:
    設定 REPORTBEHAVIOR 90

程式碼範例

當您執行下列程式碼範例時,可預覽範例報告檔名為 Colors.frx。程式碼範例會預覽報表,並使用預覽容器和預覽副檔名的處理常式中的屬性設定值的組合完全停用列印報表預覽視窗。

這個程式碼範例也會處理已在報表預覽工具列不正確存在同一個報表預覽工作階段中的顯示狀態之間的顯示設定 Visual FoxPro 9.0 物件協助報表預覽中的問題。如需有關這個問題的詳細資訊,請參閱 〈 參考 〉 一節。

這個程式碼範例會套用到 Visual FoxPro 9.0 開發環境及可執行檔,使用建立的 Visual FoxPro 到 9.0,只要您使用 Object-Assisted 報告。

若要使用這個程式碼範例,請依照下列步驟執行:
  1. 將下列程式碼儲存到 Visual FoxPro 到 9.0,在新的程式檔案,然後再執行 [程式碼。
    *----------- 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 .T.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 = NULLDO (_REPORTPREVIEW) WITH loPreviewContainer*-- Create a PREVIEW listenerloReportListener = NEWOBJECT('ReportListener')loReportListener.LISTENERTYPE = 1 &&Preview*-- Link the Listener and preview containerloReportListener.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 toolbarloExHandler = NEWOBJECT('ExtensionHandler')loPreviewContainer.SetExtensionHandler( loExHandler )REPORT FORM ;	HOME() + 'Samples\Solution\Reports\colors.frx' ;	OBJECT loReportListenerRELEASE 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 ENDDEFINE***----------- END CODE
    會開啟 [Colors.frx] 報表的預覽。

    附註以滑鼠右鍵按一下 [預覽或列印工具列上的 [報表之前,您可以從 [報表預覽視窗中進行列印。
  2. 關閉預覽],然後修改程式編輯器] 中的程式碼。
  3. 變更值為的 #DEFINE 陳述式,在程式碼的頂端。F。 若要這樣做,請尋找下列程式碼。
    #DEFINE PrintFromPreview .T.
    取代為下列程式碼:
    #DEFINE PrintFromPreview .F.
  4. 儲存程式碼中,並再執行一次。
請注意,現在您無法列印從報表預覽視窗以滑鼠右鍵按一下 [預覽或列印工具列上的 [報表預覽。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
VFP的基类
很多人估计都没听说过Visual FoxPro,简称VFP,是M
Visual FoxPro日期及时间命令
利用 _SCREEN 对象,就能对主窗口进行各种操作
VFP 高级教程:VFP 开发技巧
[豬頭記帳 Beta 5.1.0] 簡單好用的記帳軟體
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服