Home Devices
New Blog Posts: Merging Reports - Part 1 and Part 2

ppViewer error.

edited November 2004 in Devices
Hi,

I have a error when I want to preview a report in a TppViewer. The error
is: "Cannot assign a TppPage to a TppPage".

I have Application (exe file, load the module), module (bpl file with
TppViewer) and library (dll file with a report).
When I load the report and execute the TppViewer.Report.PrintToDevices,
I get the error "Cannot assign a TppPage to a TppPage".

Any idea to fix this error?.

Sumary

TFVisor = class(TFCatFrm)
ppViewer: TppViewer;
...
private
FReportForm: TdmCustomForm;
procedure SetPrint(Const Tag: Integer); override;
procedure PrintReport(aViewer: TppViewer; lForm: TdmCustomForm);
....
End;

procedure TFVisor.SetPrint(const Tag: Integer);
Type
TGenericReport = function (Const pSession: TOracleSession; FormHandle:
THandle): TdmCustomForm; stdcall;
var
GenericReport: TGenericReport;
LibHandle : THandle;
begin
Try
Case Tag Of
4, 5: Begin
LibHandle:= LoadLibrary(PChar(Copy(ClassNameForm, 9,
Length(ClassNameForm) - 8)+'.Dll'));
Try
If LibHandle <> HINSTANCE_ERROR Then
Begin
GenericReport:= GetProcAddress(LibHandle,
PChar(Copy(ClassNameForm, 5, Length(ClassNameForm) - 4)));
If Assigned(GenericReport) Then
Begin
PrintReport(ppViewer, GenericReport(Session, Handle));
End Else
ShowMessage('La libreria '+Copy(ClassNameForm, 9,
Length(ClassNameForm) - 8)+'.Dll no exporta la funcion '+
Copy(ClassNameForm, 5, Length(ClassNameForm) - 4)+'!...');
End Else
ShowMessage('No se pudo encontrar la libreria
'+Copy(ClassNameForm, 9, Length(ClassNameForm) - 8)+'.Dll!...');
Finally
FreeLibrary(LibHandle);
End;
End;
End;
Except
On E:EOracleError do ShowMessage(E.Message);
End;
End;

procedure TFVisor.PrintReport(aViewer: TppViewer; lForm: TdmCustomForm);
begin
{free any previously created report form}
If FReportForm <> nil Then
Begin
FReportForm.CloseFiles;
FReportForm.Free;
FReportForm := nil;
End;
{reset viewer to page 1}
aViewer.Reset;

If (lForm <> nil) Then
lForm.Report.Language := FDefaultLanguage;

If lForm = nil Then
MessageDlg('Forma no encontrada!...', mtWarning, [mbOK], 0)
Else
Begin
FReportForm:= lForm;
If FReportForm.Execute Then
Begin
SetCursor(crHourGlass);
If cbxPrintToArchive.Checked Then
Begin
FReportForm.OpenFiles;
FReportForm.Report.AllowPrintToArchive := True;
FReportForm.Report.ArchiveFileName := ExtractFilePath(ParamStr(0)) +
'Reports\dm' + Copy(lForm.ClassName, 5, 4) + '.raf';
FReportForm.Report.Device := dvArchive;
FReportForm.Print;
End Else
Begin
FReportForm.OpenFiles;
aViewer.Report:= FReportForm.Report; //Here put the error
InitializeSearch;
aViewer.Report.PrintToDevices;
End;
SetCursor(crDefault);
End;
End;
End;

I am using Dephi 7 Entreprise and RB 7.04.

Comments

This discussion has been closed.