Page 1 of 1

How to call Crystal Report Runtime (DLL) inside FWH?

Posted: Thu Jun 23, 2016 12:50 am
by dutch
Dear All,

I would like to call Crystal Report Runtime inside FWH+MySql. Can anyone guide me and give a sample to call Crystal Report Runtime?

Thank you in advance.

Re: How to call Crystal Report Runtime (DLL) inside FWH?

Posted: Thu Jun 23, 2016 3:08 pm
by fgondi
I use Crystal report 2013 with ADS

Code: Select all

oCRApp         := CreateObject("CrystalRuntime.Application.11") 
oCRReport     := oCRApp:OpenReport(cRpt)
oCRDatabase := oCRReport:Database
oCRTables     := oCRDatabase:Tables

oCRTable:= oCRDatabase:Tables(1)
oCRTable:ConnectionProperties:DeleteAll()

oCRDatabase:LogOnServer ('crdb_Ads', "BASE DE DATOS ADD",, cUsuario, cPassword )

For i:= 1 to oCRTables:Count()
  oCRTable:= oCRDatabase:Tables(i)
  oCRTable:SetLogOnInfo( "BASE DE DATOS ADD", , cUsuario, cPassword )
next
oCRReport:EnableParameterPrompting("False")
oCRReport:DiscardSavedData()

//Ejemplo de Parametros si hacen falta
oCRParameterField := oCRReport:ParameterFields
if oCRParameterField:Count() > 0
  oCRParameterField:GetItemByName('pFchIni'):AddCurrentValue( dFchIni )
  ...
endif


//Visor ActiveX
 DEFINE Window oVentHija MDICHILD Title cTitle
 oActiveX := TActiveX():New( oVentHija, "CrystalReports11.ActivexReportViewer.1" )  
 oVentHija:oClient := oActiveX
 oVentHija:cTitle( cTitle )
 oActivex:SetProp( "ReportSource", oCRReport )
 oActiveX:SetProp( "EnableStopButton",     1  )
 oActiveX:SetProp( "EnableAnimationCtrl",  0  )
 oActiveX:SetProp( "EnableCloseButton",    1  ) 
 oActiveX:SetProp( "EnableExportButton",   1  )
 oActiveX:SetProp( "EnablePopupMenu",      0  ) 
 oActiveX:SetProp( "EnableRefreshButton",  0  )
 oActiveX:bOnEvent = { | event, aParams | EventInfo( event, aParams, oCRReport, oActivex  ) } 

ACTIVATE WINDOW oVentHija;
 ON INIT ( oActiveX:Do( "Viewreport" ) );
 Valid ( oCRDatabase:LogOffServer ('crdb_Ads', "BASE DE DATOS ADD",, cUsuario, cPassWord ), oCRDatabase := NIL, oActiveX := NIL, oCRReport := NIL )


function EventInfo( event, aParams, oCRReport, oActivex )
   local cMsg := cValToChar( event ) //+ CRLF
return cMsg 
 

Re: How to call Crystal Report Runtime (DLL) inside FWH?

Posted: Thu Jun 23, 2016 10:05 pm
by dutch
Dear Fernando

Thank you so much. I will study from your sample.