Hola,
Le hice estos cambios a la clase para que pudiera conectarse a las tablas y
recibir parametros.
Saludos.
#include "Xailer.ch"
//---------------------------------------------------------- --------------------
CLASS TCrystalPreview FROM TForm
PROPERTY cText INIT "Crystal Reports Preview"
PROPERTY cReport
DATA oCRApp, oCRReport, hPreview
DATA nTab, oDb, oTablas, nTables
METHOD Show( nShowMode, lCenter )
METHOD Free()
METHOD GoNextControl() VIRTUAL
METHOD GoPrevControl() VIRTUAL
METHOD WMSize()
METHOD Crea()
METHOD Parametro( Nombre, Parametro )
ENDCLASS
//---------------------------------------------------------- --------------------
METHOD Parametro( Nombre, Parametro ) CLASS TCrystalPreview
::oCRReport:ParameterFields(Nombre):setCurrentValue(Parametr o)
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Crea() CLASS TCrystalPreview
IF Empty( ::Handle )
::Create()
ENDIF
::oCRApp := CreateObject( "Crystal.CRPE.Application" )
::oCRReport := ::oCRApp:OpenReport( ::cReport )
::oDb := ::oCRReport:Database()
::oTablas := ::oDb:Tables()
::nTables := ::oTablas:Count()
WITH OBJECT Tini():New(".config.ini")
FOR ::nTab := 1 TO ::nTables
::oDb:Tables(::nTab):SetLogOnInfo(:GetEntry("CONFIG","SERVER ", ""),
:GetEntry("CONFIG","BD", ""), ;
:GetEntry("CONFIG","ID", ""),
:GetEntry("CONFIG","PWD", ""))
NEXt
end
RETURN NIL
//---------------------------------------------------------- --------------------
METHOD Show( nShowMode, lCenter ) CLASS TCrystalPreview
::oCRReport:Preview( "", 0, 0, 0, 0, WS_CHILD, ::Handle )
::hPreview := GetWindow( ::Handle, GW_CHILD )
Super:Show( nShowMode, lCenter )
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD Free() CLASS TCrystalPreview
IF ::oCRReport != Nil
::oCRReport := Nil
::oCRApp := Nil
ENDIF
RETURN Super:Free()
//---------------------------------------------------------- --------------------
METHOD WMSize( nWParam, nLParam ) CLASS TCrystalPreview
MoveWindow( ::hPreview, 0, 0, LoWord( nLParam ), HiWord( nLParam ) )
RETURN Nil
//---------------------------------------------------------- --------------------
"Jose F. Gimenez" <
jfgimenez@wanadoo.es> escribió en el mensaje
news:449090dc$[email=
1@ozsrvnegro.ozlan.local...]
1@ozsrvnegro.ozlan.local...[/email]
> Rolando,
>
>> Póngala aqui maestro, y muchas gracias.
>
> Bien, aquí está. He de reconocer que parte del mérito es de René Flores.
> La forma de usarla es la siguiente:
>
> Como MDIChild:
>
> WITH OBJECT TCrystalPreview()
> :nFormType := ftMDICHILD
> :New( Self )
> :cReport := ".Subcue01.rpt"
> :Show( smMAXIMIZE )
> END
>
> Modal:
>
> WITH OBJECT TCrystalPreview():New( Self )
> :cReport := ".Subcue01.rpt"
> :ShowModal( smMAXIMIZE )
> END
>
> No modal:
>
> WITH OBJECT TCrystalPreview():New( Self )
> :cReport := ".Subcue01.rpt"
> :Show( smMAXIMIZE )
> END
>
>
> Hay que tener en cuenta que sirve para lanzar un report directo, es decir,
> que no necesita abrir tablas o suministrar nombre de usuario y contraseña.
> En ese caso habría que hacerlo a mano o completar la clase. Por cierto, si
> alguien quiere completar la clase y ponerla a disposición de todos, sólo
> tiene que enviárnosla para que la publiquemos.
>
>
> --
> Un saludo,
>
> José F. Giménez
>
http://www.xailer.com
>
>