Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal viewer disables ENTER key when switching windows??

Status
Not open for further replies.

chriscboy

Programmer
Apr 23, 2002
150
GB
Hi All,

We have recently upgraded our crystal reports and crystal report viewer to XI.

I have a form class that contains the crystal viewer control. The form WindowType property is set to modeless.

Whenever I run a report, I can switch to other windows, but for some reason can't use the enter key!! This occurs both when running a crystal report from our application and also when using the form class in a test program within the VFP IDE.

This behavior didn't occur when we where using the 8.5 crystal viewer, so I don't understand what is happening.
I only discovered this from our users today, who now cannot simutaneously use reports and other functions from our application. Also because the enter key is not working when the viewer is displayed, I cannot enter variables into the watch window when I'm debugging!!

Has anyone else experienced this, or have any ideas on how I can go about resolving this?

Thanks (much confused) :)
 
Further to my above post I have carried out some further testing by creating a small test program, which creates a form with the crystal viewer control and runs a test report.

When I run this in VFP and display the test report I can type text into the command window but not use the Enter key to execute statements. I have tried new versions of crystal XI and VFP and I still get the same behaviour. It seems the second the crystal viewer control has focus, you can no longer used the enter key in other windows which seems strange.

Is there someone out there who has Crystal XI installed on their machine to test this for me and let me know the results? You will need an example report C:\TEST.RPT to run this example. When you run the example click on the “Open test report” button, and then try and execute a statement in the command window and let me know your results?

Now for the example program:

Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show

DEFINE CLASS form1 AS form

	Top = 14
	Left = 0
	Height = 236
	Width = 375
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	ADD OBJECT text1 AS textbox WITH ;
		Height = 23, ;
		Left = 12, ;
		Top = 156, ;
		Width = 108, ;
		Name = "Text1"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 156, ;
		Left = 120, ;
		Height = 27, ;
		Width = 100, ;
		Caption = "Open test report", ;
		Name = "Command1"

	Procedure Init					
		Thisform.AddObject("oCRViewer","OleControl","CrystalReports11.ActiveXReportViewer.1")
		Thisform.ocrviewer.Top = 12
		Thisform.ocrviewer.Left = 12
		Thisform.ocrviewer.Height = 120
		Thisform.ocrviewer.Width = 200				
		Thisform.ocrviewer.Visible = .T.
	EndProc

	PROCEDURE Load
		Sys(2333,1)
	ENDPROC

	PROCEDURE text1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		If nkeycode=10 or nkeycode=13
			MessageBox ("ENTER")
		EndIf
	ENDPROC

	PROCEDURE command1.Click
		Local oCR As CRAXDRT.Application
		Local oRep AS CRAXDRT.Report
		oCR = CreateObject("CrystalRunTime.Application.11")
		oRep = oCR.OpenReport("c:\test.rpt")
		Thisform.oCRViewer.ReportSource = oRep 
		Thisform.oCRViewer.ViewReport()
	ENDPROC

ENDDEFINE
 
I am using VFP7 SP1 and Windows XP SP2.

I have also tried the test program using VFP9, and using the crystal viewer that ships with Crystal 2008. The same behaviour still occurs.
 
Finally managed to get a workaround for this problem. If you make the crystal viewer object invisible and then visible gain, the ENTER key continues to work in other windows!

Below is the code I put in the LostFocus event of the class to resolve the issue:
With Thisform
.LockScreen = .T.
.oCRViewer.Visible = .F.
.oCRViewer.Visible = .T.
.LockScreen = .F.
EndWith

Most bizzare!!
 
Hi Chris,

I see you found a workaround, but I suggest you try this following ....

In the Load event of the form that hosts the viewer control, execute SYS(2333,1). Then, in the Unload, do the reverse, that is, SYS(2333,0).

I don't know if that will solve this specific problem, but it does get rid of other weirdnesses with the CR viewer control (and also some other ActiveX controls), so might be worth a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top