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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports changing working directory!

Status
Not open for further replies.

jeisner

Programmer
Jul 23, 2001
26
0
0
AU
When a crystal report is brought up (using OCX Crystal32 control) under foxpro version 6, and then the report is exported to a mail recipiant, crystal seems to change the working directory, so when I return to my application and it is assuming that the working directory has not changed it will crash......

How do you stop the silly crystal reports from changing the working directory?
 
jeisner

You may want to "remember" where you were, and record it in a variable.
Code:
Local oldPath
STORE sys(5)+CURDIR() TO OldPath
&& Create your Crystal report here
CD &OldPath


Mike Gagnon
 
Yeah that doesn't work properly, you see the problem is when you create/display the crystal report it doesn't change the directory, it is only if the user clicks the export button on the crystal window and exports to MAPI then the working directory changes.

Unfortunately if I followed your directions (tried something similar b4) the code to display report is executed and then fox executes the code to fix the path, meanwhile the crystal window is still open, whereupon the user exports to email and the directory is changed. When they close the crystal reports window (returning to foxpro) I can't even use the Gotfocus event to fix the directory as foxpro doesn't register Gotfocus when the focus is returned from an external application, only from another form within itself!
 
Nobody has any ideas as to what event triggers if the application no longer has focus? sad if fox can't do it!
 
jeiser

I believe it's a Crystal problem more then a VFP problem. You said it yourself "crystal seems to change the working directory," Mike Gagnon
 
Yeah I understand it is a problem of Crystal Reports: however I am going to have to use Foxpro to get around the problem.

Now one way to do this would be if I could tell when my foxpro application lost focus (not the form the entire application) and when it got focus back again, whereupon I could reset the directory in my application. But I have found that gotfocus does not work in foxpro if you go to and come back from another application, gotfocus only works if focus is lost and returned from an object (form) within the foxpro application.

Does anyone know a way to tell when your foxpro APPLICATION has regained focus!
 
jeisner

How about minimizing your application. That you can determine when you maximize it again because you have to issue the :
_SCREEN.WINDOWSTATE = 2
Mike Gagnon
 
I didn't know you could trap the maximise? how exactly is that done?

P.S. Thanks for the ideas!
 
jeisner

What I'm suggesting is something like, in the click of your "go to Crystal report " button do something like:
_SCREEN.WINDOWSTATE = 1 && Minimized
** Save directory info
** Go to Crystal
_SCREEN.WINDOWSTATE = 2 && Maximized
** reset the directory

Mike Gagnon
 
Just as a side note for anyone else that may read this thread, it is probably MAPI functions changing the working directory.

CurPath = SYS(5) + SYS(2003)
... do mail stuff
SET DEFAULT TO (CurPath)
Dave S.
 
DSummZZZ

Just as a side note for anyone else that may read this thread, it is probably MAPI functions changing the working directory.

CurPath = SYS(5) + SYS(2003)
... do mail stuff
SET DEFAULT TO (CurPath)


Either that or read my first suggestion (-:


Mike Gagnon
 
I saw your first post re (CD). For some reason, I've had trouble with CD when using it in program code. Hence the SET DEFAULT post. I love it in the command window though.
Dave S.
 
DSummZZZ

I saw your first post re (CD). For some reason, I've had trouble with CD when using it in program code. Hence the SET DEFAULT post. I love it in the command window though.

Been using CD since the FPD days...works for me....
Mike Gagnon
 
DSummZZZ
I don't believe you. FPD didn't have CD.

Really? I don't have FPD anywhere to test, but I was sure...

Mike Gagnon
 
LOL,

Thanks again, and yes it is the Crystal Reports internal MAPI function that changes the working directory. Everything is fine until the client uses the MAPI export and the working directory gets changed..... Wish I could make the Crystal Window Modal as that would make life a lot easier (and safer)...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top