Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with CR 8.5 and VFP9
Message
De
17/04/2007 12:09:41
Ken Penrod
Technical Perspectives, Inc.
Richardson, Texas, États-Unis
 
 
À
30/04/2005 17:39:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01008667
Message ID:
01216808
Vues:
16
Craig,
Two years ago we were having this problem and opted not to upgrade to VFP9 because of deadlines. Now we're revisiting this. I tried putting your code in the Release of the form but the Release never fires and thus no Destroy either. When I click on the form close (X) nothing happens. It's as if it'be been 'highjacked'.


Ken

>In the Release method of the form, try:
>
>This.oleCRViewer = NULL
>
>
>>Craig,
>> We're not getting any error messages. I'm calling preview with...
>>
>> loCRForm = CREATEOBJECT("cfrmCrystal", lcRpt, lcTable, , lcFormCaption)
>> loCRForm.DoPreview()
>>

Here's the complete Class definition
	DEFINE CLASS cfrmCrystal AS form

		Caption = 'Report Preview'
		
		oCrystalReports = NULL
		oReport         = NULL
		oDB             = NULL
		oCDBT           = NULL
		oDBT            = NULL
		oExp			= NULL
		cTableName      = ""
		cReportName     = ""
		cP2FName		= ""
		nCopies         = 1
		WindowState     = 2		&&	Maximized

		WindowType		= 1		&&	Modal Dialog
					
		Closable        = .t.
		nOrient			= 1
		lP2F			= .F.

		PROCEDURE Init(tcReportName AS String, ;
		               tcTableName AS String, ;
		               tnCopies AS Integer, ;
		               tcFormCaption AS String, ;
		               tlP2F AS Logical, ;
		               tcP2FName AS String, ;
		               tnOrient as Integer ;
		                   ) AS Boolean

			_VFP.AutoYield = .F.		&&	We're hosting an ActiveX control in a form, so...
					                   
			WITH Thisform
				IF VARTYPE(tcReportName) = "C"
					.cReportName = tcReportName
				ENDIF
				IF VARTYPE(tcTableName) = "C"
					.cTableName = tcTableName
				ENDIF
				IF VARTYPE(tnCopies) = "N"
					.nCopies = tnCopies
				ENDIF
				IF VARTYPE(tcFormCaption) = "C"
					.Caption = tcFormCaption
				ENDIF
				IF VARTYPE(tlP2F) = "L"
					.lP2F = tlP2F
				ENDIF
				IF VARTYPE(tcP2FName) = "C"
					.cP2FName = tcP2FName
				ENDIF
				IF VARTYPE(tnOrient) = "N"
					.nOrient = tnOrient
				ENDIF
				.closable = .t.
			ENDWITH 
		ENDPROC
		
		PROCEDURE BuildCRObjects
			WITH Thisform
				.oCrystalReports = CREATEOBJECT("CrystalRuntime.Application")
				.oReport         = .oCrystalReports.OpenReport(.cReportName)
				.oDB             = .oReport.Database
				.oCDBT           = .oDB.Tables()
				.oDBT            = .oCDBT.Item(1)

				.oDB.Verify()

				.oDBT.SetTableLocation(.cTableName,JUSTFNAME(.cTableName),"")
				=VFPDelay(2)
				.oDB.Verify()


				IF FILE('Crystal.txt')
					NAME1 = .oDBT.name
					.oDBT.name = XXX
					MESSAGEBOX("Please record the following:  " + CHR(13) + CHR(13) + ;
					           "DLL Name = " + .oDBT.dllname + CHR(13) + ;
					           "Name1    = " + name1 + CHR(13) + ;
					           "Name     = " + .oDBT.name + CHR(13) + ;
					           "Location = " + .oDBT.location + CHR(13),0)
				ENDIF 

				IF .oReport.HasSavedData
					.oReport.DiscardSavedData()
				ENDIF

				lnNumPrint = APRINTERS(laPrinters)
				IF lnNumPrint > 0
					FOR ii = 1 TO lnNumPrint
						IF SET("PRINTER",3) = UPPER(laPrinters(ii,1))
							.oReport.SelectPrinter(.oReport.DriverName,SET("PRINTER",3),laPrinters(ii,2))
							EXIT 
						ENDIF 
					ENDFOR 
				ELSE
					=GETCHOIC('There are no printing devices attached to this computer.','OK')
				ENDIF 
	
				.oReport.PaperOrientation = .nOrient

			ENDWITH
		ENDPROC

		PROCEDURE DoPreview
			WITH Thisform
				ASSERT NOT EMPTY(.cReportName) MESSAGE ;
					[Report name has not been set.]
				ASSERT NOT EMPTY(.cTableName) MESSAGE ;
					[Table name has not been set.]
				
				.BuildCRObjects()
				.AddObject("oleCRViewer", "oleControl", "crViewer.crViewer")
			ENDWITH

			WITH Thisform.oleCRViewer
				* Set report viewer Properties.
				.DisplayGroupTree         = .F.
				.DisplayTabs              = .F.
				.EnableDrillDown          = .F.
				.EnableExportButton       = .F.
				.EnableGroupTree          = .F.
				.EnableHelpButton         = .F.
				.EnableNavigationControls = .T.
				.EnablePopupMenu          = .F.
				.EnablePrintButton        = .F.
				.EnableRefreshButton      = .F.
				.EnableSearchControl      = .F.
				.EnableStopButton         = .F.
				.EnableZoomControl        = .T.
				.EnableCloseButton        = .T.
				.ReportSource = Thisform.oReport
				.ViewReport()
			ENDWITH 
			Thisform.Show()
		ENDPROC
		
		PROCEDURE DoPrint
			WITH Thisform
				ASSERT NOT EMPTY(.cReportName) MESSAGE ;
					[Report name has not been set.]
				ASSERT NOT EMPTY(.cTableName) MESSAGE ;
					[Table name has not been set.]
				ASSERT .nCopies > 0 MESSAGE ;
					[Number of copies must be an integer 1 or higher.]
				
				.BuildCRObjects()
			
				IF .lP2F
					.oExp = .oReport.ExportOptions()
					.oExp.DestinationType = 1
					.oExp.FormatType = 31		&& PDF Format
					.oExp.DiskFileName = .cP2FName
					.oReport.Export(.F.)
				ELSE 
					.oReport.Printout(.F., .nCopies)
				ENDIF 
			ENDWITH
		ENDPROC
		
		PROCEDURE Error
			LPARAMETERS nError, cMethod, nLine
			
			IF nError != 1440
				DODEFAULT()
			ENDIF
		ENDPROC
		
		PROCEDURE Resize
			WITH This
				.oleCRViewer.Top = 1
				.oleCRViewer.Left = 1
				.oleCRViewer.Height = .Height - 2
				.oleCRViewer.Width = .Width - 2
			ENDWITH 
		ENDPROC 
		
		PROCEDURE Load
			SYS(2333,1) 
		ENDPROC 
		
		PROCEDURE Activate
			WITH This.oleCRViewer
				.Top = 5
				.Left = 5
				.Height = ThisForm.Height - 2
				.Width = ThisForm.Width - 2
			ENDWITH
			ThisForm.Resize()			
		ENDPROC


		*- If passed report does not have an extension, assign "RPT" to it.
		PROCEDURE cReportName_Assign(tcValue AS String) AS TextBox
			IF EMPTY(JUSTEXT(tcValue))
				tcValue = FORCEEXT(tcValue, "RPT")
			ENDIF
			This.cReportName = tcValue
			RETURN This.cReportName
		ENDPROC

		*- If passed table does not have an extension, assign "DBF" to it.
		PROCEDURE cTableName_Assign(tcValue AS String) AS TextBox
			IF EMPTY(JUSTEXT(tcValue))
				tcValue = FORCEEXT(tcValue, "DBF")
			ENDIF
			This.cTableName = tcValue
			RETURN This.cTableName
		ENDPROC

		PROCEDURE Destroy
			WITH This
				.Deactivate()
				
				.oExp			 = NULL
				.oDBT            = NULL
				.oCDBT           = NULL
				.oDB             = NULL
				.oReport         = NULL
				.oCrystalReports = NULL
				
				*-- This object only exists if DoPreview() has been called				
				IF PEMSTATUS(This,"oleCRViewer", 5)

					.oleCRViewer = NULL

					.RemoveObject("oleCRViewer")
					

				ENDIF
			ENDWITH

			

		ENDPROC

		PROCEDURE Release
			IF PEMSTATUS(Thisform,"oleCRViewer", 5)
				thisform.oleCRViewer = NULL		
			ENDIF 
		ENDPROC 
				
	ENDDEFINE
>>
>>I'm trying to close it by clicking on the close box (X) on the window which works fine in VFP7 and VFP8.
>>
>>'Tis a puzzlement.
>>
>>Ken
>>
>>
>>>REPORTBEHAVIOR effects only VFP reports and will not have any effect on Crystal Reports. Are you getting any error messages? How are you creating and trying to close the preview window?
>>>
>>>>Are there any known issues with CR 8.5 and VFP9? When I try to run my CR report from within my VFP9 app I can get the preview window but can not close it. I've set REPORTBEHAVIOR to 80. CR runs just fine within my VFP8 version of the app.
>>>>
>>>>Thanks,
>>>>Ken
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform