Partager via


Report Protection Flags

Visual FoxPro 9.0 introduces a new keyword to the MODIFY REPORT | LABEL command: PROTECTED. When a report or label layout is opened in protected mode, various capabilities of the designer are disabled or restricted depending on the protection settings set by the developer.

There are two types of protection settings: Those that apply to the entire report layout; and those that apply to specific report elements (a control or band).

In Visual FoxPro 9.0, you adjust protection settings for a layout in the user interface provided by the default Report Builder application. The native dialog boxes of the Report Designer do not expose a way to edit protection flags.

Protection Flags

Types of Protection flags

The following constants are defined in the file foxpro_reporting.h, located in the ..\FFC\ directory.

Note that these constant values represent the bit position of each flag, not the actual integer value of the flag.

Protection flags for report controls

Constant in foxpro_reporting.h

Value

Description

FRX_PROTECT_OBJECT_LOCK

0

A report control with this flag set can not be moved (relative to its band) or resized using the mouse or keyboard. It can be selected, double-clicked, and edited through the native Report Designer dialog boxes. Resizing a band above the one in which the object is located will still result in the object being moved relative to the top of the report, as expected.

FRX_PROTECT_OBJECT_HIDE

1

A report control with this flag set is not visible in the designer.

FRX_PROTECT_OBJECT_NO_DELETE

2

A report control with this flag set may not be deleted or cut. You can select it, copy it to the edit clipboard with Ctrl-C, and paste a new control into the report layout.

Important Note:

With no report builder active, the protection flags will be retained along with the other report control attributes. This means that you will not be able to remove the newly pasted report control. For this reason, the default report builder, ReportBuilder.App, automatically removes protection flags from the newly created report control during the paste operation. This behavior is implemented in the PasteUnprotectFilter class, registered by default in the Report Builder's handler table. See Report Builder Event Handler Registry Table for more information.

FRX_PROTECT_OBJECT_NO_EDIT

3

For report controls with this flag set, double-clicking has no effect, and you can not display the object's context menu with a right-click. Basically there is no access to the object's Properties dialog.

FRX_PROTECT_OBJECT_NO_SELECT

6

A report control with this flag set may not be selected with the mouse or TAB key. The resize handles do not appear. This flag implicitly has the same effect as OBJECT_NO_EDIT + OBJECT_LOCK.

Generally speaking, for most practical purposes:

  • NO_SELECT protection effectively includes the behavior of LOCK + NO_EDIT + NO_DELETE protection, even if those flags are not explicitly set.

  • HIDDEN protection effectively includes the behavior of LOCK + NO_EDIT + NO_DELETE + NO_SELECT protection, even if those flags are not explicitly set.

Protection flags for report bands

Constant in foxpro_reporting.h

Value

Description

FRX_PROTECT_BAND_NO_EDIT

4

The Band Properties dialog box is not available. Double-clicking on the band has no effect.

FRX_PROTECT_BAND_NO_RESIZE

14

The vertical size of the band is locked. The band cannot be resized in the designer.

Protection flags for report controls

Constant in foxpro_reporting.h

Value

Description

FRX_PROTECT_REPORT_NO_PREVIEW

7

Report layout may not be previewed.

FRX_PROTECT_REPORT_NO_OPTBAND

8

Optional Bands dialog box is not available.

FRX_PROTECT_REPORT_NO_GROUP

9

Data Grouping dialog box is not available.

FRX_PROTECT_REPORT_NO_VARIABLES

10

Report Variables dialog box is not available.

FRX_PROTECT_REPORT_NO_PAGESETUP

11

Page Setup dialog box is not available.

FRX_PROTECT_REPORT_NO_DATAENV

13

The Data Environment of the layout can not be modified.

FRX_PROTECT_REPORT_NO_PRINT

15

The report can not be printed from within the designer. The Run Report and Print… options of the menu are disabled.

How Protection Flags are stored with the layout

Protection flags are stored in the ORDER memo field of the FRX structure, in the header record and separately in each control and band record.

If you are not using the default report builder, you can adjust the flags by opening the .frx or .lbx file and replacing the value stored in the ORDER field with an alternative value determined by the following method:

Protection flag values are summed and stored as binary character data in the ORDER field. For example: FRX_PROTECT_OBJECT_LOCK + FRX_PROTECT_OBJECT_NO_DELETE + FRX_PROTECT_NO_EDIT = 2^0 + 2^2 + 2^3 = 1+4+8 = 13. Therefore, the ORDER field will contain CHR(13).

The FRX Cursor foundation class includes a couple of methods that are useful in extracting and replacing protection flags, as shown in the example below.

Example

#INCLUDE foxpro_reporting.h
LOCAL oFrxHelper, cReport, iFlags

* Create the helper object:
oFrxHelper = NEWOBJECT( "frxCursor", HOME()+ "\FFC\_frxcursor.vcx")

* Select a report file:
cReport = GETFILE("FRX")

* Open a report layout as a table:
USE (m.cReport) ALIAS frx

* Go to the report header record:
LOCATE FOR frx.objtype = FRX_OBJTYP_REPORTHEADER and ;
           frx.objcode = FRX_OBJCOD_REPORTHEADER and ;
           frx.platform = FRX_PLATFORM_WINDOWS

* Extract the current protection setting:
iFlags = oFrxHelper.BinStringToInt( frx.ORDER )

* Prevent access to the Report Variables dialog box:
iFlags = BITSET( iFlags, FRX_PROTECT_REPORT_NO_VARIABLES )

* Save back to the frx record:
REPLACE frx.order WITH oFrxHelper.IntToBinString( iFlags )
USE IN frx

* Edit the report in protected mode:
MODIFY REPORT FORM (cReport) PROTECTED

See Also

Reference

FRX Cursor Foundation Class

Protection Tab, Report Properties Dialog Box (Report Builder)

Protection Tab, Report Band Properties Dialog Box (Report Builder)

Protection Tab, Report Control Properties Dialog Box (Report Builder)