TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Keeping Forms Open when Changing Directories
 
   
by Lance Leonard 
 Posted: 12 July 2000
 
   
 
 Applies to: Paradox 5.0
 
   
 
Audience: Intermediate
 
       
   

Question: I need to change the working directory. When I do this, Paradox closes my forms. How can I keep them open?

Answer: By overriding the default behavior of the form's menuChangingWork menuAction() and setting the menuAction's eventInfo errorCode() to a non-zero value. For example, consider the following code:

   method menuAction( eventInfo menuEvent )

      if not eventInfo.isPreFilter() then ; execute for form only
         if eventInfo.id() = menuChangingWork then
            eventInfo.setErrorCode( userError )
         endIf
      endIf

   endMethod

This also works with changing the private directory. To keep forms in this case, replace the menuChangingWork constant with menuChangingPriv.

Since menuAction is only supported on forms, this means you cannot keep reports, scripts, or libraries open when changing the working or private directories. To work with this limitation, add code that reopens the these documents after the default behavior of the relevant constant. For example, the following code shows how to re-open a library after changing the working directory:

   method menuAction( eventInfo menuEvent )

      if not eventInfo.isPreFilter() then ; execute for form only
         if eventInfo.id() = menuChangingWork then
            eventInfo.setErrorCode( userError )
            doDefault
            openLibrary()  ; custom method for opening library
         endIf
      endIf

   endMethod

Note: There are very few cases where this is really necessary. If you find yourself needing this behavior in many applications, you may wish to consider using aliases more heavily. There are legitimate uses for this technique, however, you should use it sparingly.

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 01 June 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]