Visual FoxPro 9.0에서 보고서 미리 보기에서 인쇄 방지

이 문서에서는 Visual FoxPro 9.0에서 Object-Assisted Reporting을 사용하여 보고서를 미리 보는 동안 보고서를 인쇄하는 옵션을 사용하지 않도록 설정하는 방법을 보여줍니다.

원래 제품 버전: Visual FoxPro
원본 KB 번호: 895279

요약

Microsoft Visual FoxPro 9.0에는 Object-Assisted Reporting 아키텍처가 도입되었습니다. 이 새로운 디자인을 사용하면 보고서 디자이너 및 보고서 미리 보기와 같은 Visual FoxPro 9.0 보고 도구를 사용하여 코드를 통해 직접 인터페이스할 수 있습니다. 따라서 이전 버전의 Visual FoxPro보다 Visual FoxPro 9.0의 보고서 미리 보기에서 인쇄하는 기능을 사용하지 않도록 설정하는 것이 더 쉽습니다. 이 문서에서는 직접 상호 작용하고 Object-Assisted 보고 보고서 미리 보기를 구성하는 코드를 작성하는 방법을 설명합니다.

추가 정보

기본적으로 Visual FoxPro 9.0에서 Object-Assisted 보고서를 미리 볼 때 사용자는 다음 방법 중 하나를 사용하여 보고서 미리 보기 창에서 보고서를 인쇄할 수 있습니다.

  • 보고서 미리 보기 도구 모음에서 인쇄 단추를 클릭합니다.
  • 보고서 미리 보기 창 내부를 마우스 오른쪽 단추로 클릭한 다음 인쇄를 클릭합니다.

이 옵션을 사용하지 않도록 설정할 수 있습니다. 이전 버전의 Visual FoxPro에서는 Visual FoxPro 리소스 파일(FoxUser.dbf)을 변경해야 했습니다.

Visual FoxPro 9.0에서는 보고서 미리 보기 창에서 인쇄를 사용하지 않도록 FoxUser.dbf 파일을 변경할 수 있습니다. 그러나 Object-Assisted Reporting이 도입되면 대체 방법을 사용할 수 있습니다. 기본적으로 Visual FoxPro 9.0의 Object-Assisted 보고는 사용하도록 설정되지 않습니다. 사용하도록 설정하려면 설정을 변경 REPORTBEHAVIOR 해야 합니다. 이렇게 하려면 다음 방법 중 하나를 사용합니다.

  • 메서드 1, Visual FoxPro IDE를 통해 보고서 엔진 동작 설정 변경:

    1. 도구 메뉴에서 옵션을 클릭합니다.
    2. 옵션 대화 상자에서 보고서 탭을 클릭한 다음 보고서엔진 동작 목록에서 90(개체 지원)을 선택합니다.
    3. (선택 사항) Visual FoxPro 9.0 세션 간에 이 설정을 유지하려면 옵션 대화 상자에서 기본값으로 설정을 클릭합니다.
  • 메서드 2, 코드에서 다음 명령을 실행하여 Object-Assisted 보고를 사용하도록 설정합니다.

    SET REPORTBEHAVIOR 90.

코드 샘플

다음 코드 샘플을 실행하면 Colors.frx라는 샘플 보고서 파일이 미리 보기로 표시됩니다. 코드 샘플은 보고서를 미리 보고 미리 보기 컨테이너 및 미리 보기 확장 처리기의 속성 설정 조합을 사용하여 보고서 미리 보기 창에서 인쇄를 완전히 사용하지 않도록 설정합니다.

또한 이 코드 샘플은 보고서 미리 보기 도구 모음이 동일한 보고서 미리 보기 세션의 모양 간에 표시 설정을 올바르게 유지하지 않는 Visual FoxPro 9.0 Object-Assisted 보고서 미리 보기의 문제를 해결합니다.

이 코드 샘플은 Visual FoxPro 9.0 개발 환경과 visual FoxPro 9.0을 사용하여 만든 실행 파일에 모두 적용되며 Object-Assisted Reporting을 사용하는 한 적용됩니다.

이 코드 샘플을 사용하려면 다음 단계를 수행합니다.

  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 = 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 ENDDEFINE
    *
    *
    *----------- END CODE
    

    Colors.frx 보고서의 미리 보기가 열립니다.

    참고

    미리 보기를 마우스 오른쪽 단추로 클릭하거나 보고서 미리 보기 도구 모음에서 인쇄를 클릭하여 보고서 미리 보기 창에서 인쇄 할 수 있습니다.

  2. 미리 보기를 닫은 다음 프로그램 편집기에서 코드를 수정합니다.

  3. 코드 맨 위에 있는 #DEFINE 문을 .F 값으로 변경합니다. 이렇게 하려면 다음 코드를 찾습니다.

    #DEFINE PrintFromPreview .T.
    

    그리고 다음 코드로 바꿉니다.

    #DEFINE PrintFromPreview .F.
    
  4. 코드를 저장한 다음 다시 실행합니다.

참고

이제 미리 보기를 마우스 오른쪽 단추로 클릭하거나 보고서 미리 보기 도구 모음에서 인쇄를 클릭하여 보고서 미리 보기 창에서 인쇄 할 수 없습니다.