Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
81
Добавлен:
11.05.2015
Размер:
2.11 Mб
Скачать

Considerations when using the export functions

The export functions are complex function calls. To avoid errors when exporting report files from your application, keep the following things in mind:

In order to use PEGetExportOptions, Volume 2, Chapter 1 and PEExportOptions, Volume 2, Chapter 1, you must be using the version of the Crystal Report Engine (CRPE32.DLL) that came with the Professional Edition of Seagate Crystal Reports. If you have an earlier version of CRPE32.DLL installed on your machine and its earlier in the path, the program may find it first and not find the export functions. This can happen particularly if you are upgrading to the Professional Edition of Seagate Crystal Reports from the version of Seagate Crystal Reports that was shipped with Visual Basic Professional Edition. Visual Basic included an earlier version of CRPE32.DLL. Search your disk and delete or rename earlier versions of CRPE32.DLL, or make appropriate adjustments to your path statement.

Make sure all format DLLs and destination DLLs are located in the same directory as CRPE32.DLL. Once Windows finds CRPE32.DLL, it will expect all of the DLL files to be in the same directory. Format DLLs are all UXF*.DLL files and Destination DLLs are all UXD*.DLL files. As a general rule, it is best to keep all of these files in the \CRW directory or the directory into which you installed Seagate Crystal Reports. Also, make certain that the PATH statement in your AUTOEXEC.BAT file includes \CRW.

The UXF*.H and UXD*.H header files are only necessary when compiling your application. These files should be copied to the same directory as your application's source files.

Handling Preview Window Events

Using the Crystal Report Engine API, you can create a Windows CALLBACK function to handle events that occur in a preview window. For instance, if a user clicks on a button in the toolbar of the preview window, such as the Zoom button or the Next Page button, Windows registers an event for the preview window.

Using the Event functions in the Crystal REAPI, you can add instructions to your own applications to perform specific actions according to events that occur in a preview window. The sample code below demonstrates how to handle preview window events by creating a CALLBACK function for the preview window, then initializing the preview window with that CALLBACK function in your Crystal Report Engine code. The code can handle toolbar button events, Group Tree events, and even drill-down events.

The Crystal Report Engine API Event functions are only valid when a print job is sent to a preview window using PEOutputToWindow.

#include “crpe.h” #include “Windows.h”

//The EventCallback function is defined as a standard

//Windows CALLBACK procedure. Return TRUE to allow the

//Crystal Report Engine to provide default behavior.

//Return FALSE to prevent default behavior from being carried out.

Crystal Report Engine

97

//The comment TODO indicates where you need to add event

//handling code specific to your application.

#if defined (WIN32)

BOOL CALLBACK EventCallback (short eventID,

void *param, void *userData)

#else

BOOL CALLBACK __export EventCallback (short eventID,

void *param, void *userData)

#endif

{

switch(eventID)

{

case PE_CLOSE_PRINT_WINDOW_EVENT: case PE_PRINT_BUTTON_CLICKED_EVENT: case PE_EXPORT_BUTTON_CLICKED_EVENT:

case PE_FIRST_PAGE_BUTTON_CLICKED_EVENT: case PE_PREVIOUS_PAGE_BUTTON_CLICKED_EVENT: case PE_NEXT_PAGE_BUTTON_CLICKED_EVENT: case PE_LAST_PAGE_BUTTON_CLICKED_EVENT: case PE_CANCEL_BUTTON_CLICKED_EVENT:

case PE_ACTIVATE_PRINT_WINDOW_EVENT: case PE_DEACTIVATE_PRINT_WINDOW_EVENT:

case PE_PRINT_SETUP_BUTTON_CLICKED_EVENT: case PE_REFRESH_BUTTON_CLICKED_EVENT:

{

PEGeneralPrintWindowEventInfo * eventInfo = (PEGeneralPrintWindowEventInfo *) param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_GENERAL_PRINT_WINDOW_EVENT_INFO);

// TODO

}

break;

case PE_ZOOM_LEVEL_CHANGING_EVENT:

{

PEZoomLevelChangingEventInfo * eventInfo = (PEZoomLevelChangingEventInfo *) param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_ZOOM_LEVEL_CHANGING_EVENT_INFO);

// TODO

}

break;

Crystal Report Engine

98

case PE_GROUP_TREE_BUTTON_CLICKED_EVENT:

{

PEGroupTreeButtonClickedEventInfo * eventInfo = (PEGroupTreeButtonClickedEventInfo *)param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_GROUP_TREE_BUTTON_CLICKED_EVENT_INFO);

// TODO

}

break;

case PE_CLOSE_BUTTON_CLICKED_EVENT:

{

PECloseButtonClickedEventInfo *eventInfo = (PECloseButtonClickedEventInfo *)param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_CLOSE_BUTTON_CLICKED_EVENT_INFO);

// TODO

}

break;

case PE_SEARCH_BUTTON_CLICKED_EVENT:

{

PESearchButtonClickedEventInfo *eventInfo = (PESearchButtonClickedEventInfo *)param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_SEARCH_BUTTON_CLICKED_EVENT_INFO);

// TODO

}

break;

case PE_SHOW_GROUP_EVENT:

{

PEShowGroupEventInfo * eventInfo = (PEShowGroupEventInfo *)param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_SHOW_GROUP_EVENT_INFO);

// TODO

}

break;

case PE_DRILL_ON_GROUP_EVENT:

{

PEDrillOnGroupEventInfo * eventInfo =

Crystal Report Engine

99

(PEDrillOnGroupEventInfo *) param; ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_DRILL_ON_GROUP_EVENT_INFO);

// TODO

}

break;

case PE_DRILL_ON_DETAIL_EVENT:

{

PEDrillOnDetailEventInfo * eventInfo = (PEDrillOnDetailEventInfo *) param;

ASSERT(eventInfo != 0 && eventInfo->StructSize == PE_SIZEOF_DRILL_ON_DETAIL_EVENT_INFO);

// TODO

}

break;

case PE_READING_RECORDS_EVENT:

{

PEReadingRecordsEventInfo * readingRecordsInfo = (PEReadingRecordsEventInfo *) param;

ASSERT(readingRecordsInfo != 0 && readingRecordsInfo->StructSize == PE_SIZEOF_READING_RECORDS_EVENT_INFO);

// TODO

}

break;

case PE_START_EVENT:

{

PEStartEventInfo * startEventInfo = (PEStartEventInfo *) param;

ASSERT(startEventInfo != 0 && startEventInfo->StructSize == PE_SIZEOF_START_EVENT_INFO);

// TODO

}

break;

case PE_STOP_EVENT:

{

PEStopEventInfo * stopEventInfo =

Crystal Report Engine

100

(PEStopEventInfo *) param; ASSERT(stopEventInfo != 0 &&

stopEventInfo->StructSize == PE_SIZEOF_STOP_EVENT_INFO);

// TODO

}

break;

default:

break;

}

return TRUE;

}

//call this function after open a print job

//before call PEStartPrintJob

BOOL initializeEvent(short printJob)

{

//initialize window options

//do not have to set window options to get events,

//however, some of the events are fired only when

//certain window options are on.

PEWindowOptions windowOptions; windowOptions.StructSize = PE_SIZEOF_WINDOW_OPTIONS;

PEGetWindowOptions(printJob, &windowOptions);

windowOptions.hasGroupTree = TRUE; windowOptions.hasSearchButton = TRUE; windowOptions.canDrillDown = TRUE;

if(!PESetWindowOptions(printJob, &windowOptions)) return FALSE;

//enable event.

//by default, events are disabled.

PEEnableEventInfo eventInfo;

eventInfo.StructSize = sizeof(PEEnableEventInfo); eventInfo.activatePrintWindowEvent = PE_UNCHANGED; eventInfo.closePrintWindowEvent = TRUE; eventInfo.startStopEvent = TRUE; eventInfo.printWindowButtonEvent = PE_UNCHANGED; eventInfo.drillEvent = TRUE; eventInfo.readingRecordEvent = TRUE;

Crystal Report Engine

101

Соседние файлы в папке crystal