Paradox Community
Search:

 Welcome |  What is Paradox |  Paradox Folk |  Paradox Solutions |
 Interactive Paradox |  Paradox Programming |  Internet/Intranet Development |
 Support Options |  Classified Ads |  Wish List |  Submissions 


Paradox Newsgroups  |  Paradox Web Sites  |  Paradox Book List  |  FAQs From The Corel FAQ Newsgroup  



Subject: TIP:PdoxWin:Recommended way of Invoking a 
Form:2000.03.25

Version 1.0 (2000.03.25)
edited by Paradox FAQ Team
Reposted by Mike Irwin: 2001.02.10

====================
0. Introduction
====================
This FAQ addresses the frequent request for an example of a
recommended way of opening a form from a form, script, or
library.

-------------------------------
 0.1 Legal Info and Disclaimers
-------------------------------
Paradox is a trademark of Corel.
Borland Database Engine (BDE) is a trademark of Inprise.
The information provided in this FAQ is provided "as is" 
and is not warranted in any way. The information provided 
in this FAQ is not endorsed or authorized by Corel or 
Inprise in any shape, form, or manner. 

The editors claim NO responsibility for ANY illegal 
activity regarding this file, or as a result of someone 
reading this file.

You may distribute this file, as long as the copies are
complete, unaltered, and are in electronic form only.

-------------
 0.2 Feedback
-------------
Please send feedback in a Corel Paradox newsgroup or the
HREF="news:comp.databases.Paradox"news:comp.databases.
Paradox newsgroup to any of the FAQ Team mentioned in the 
"FAQ: FAQ FAQ" document.

Please preface the subject of your post with the string
"PDXWIN FAQ" to alert Team members to the function of
the message.

Please specify the FAQ name and section number the
comment applies to, if any.

======================
1. General Information
======================
With the benefit of some ten years of working with Paradox 
for Windows, this is recommendable technique for opening a 
form. This example waits on the form to return before 
continuing. This is also a recommended practice, as it has 
been found that people get confused with too many open 
windows, especially when they only have a relatively small 
acreen area (15" screen or less).

==========
2. Example
==========
This example is in a number of parts, as code will be 
placed in a number of places. Each part corresponds to just 
one module of code.

Each section explains both what the code does and why it is 
used.

-------------------------------
2.1 The Invocation Code
-------------------------------
The following code might be found in a pushButton() method 
whose
sole function is to invoke another form.

var
   foFormName        Form
endVar
   if foFormName.open(":FormAlias:FormName",
         WinStyleDefault + WinStyleHidden)
   then
      if foFormName.wait() then
         foFormName.close()
;              put code here to see if anything 
;              must be done
;              as a result of using the form.
      endif
      bringToTop()
;     if you are using menus, re-show them here
   else
      msgStop("Error",
               "Unable to open form 'FormName'.")
      bringToTop()
      return
   endif

You must replace "FormName" with the name of the form, and
"FormAlias" with the name of the alias with your forms.

Notes:

1. The form variable is named after the form to be opened.
   This is good programming practice, as it links the two
   together when someone else reads it (or you, in months
   to come !).
2. The style of the form is expressed explicitly. This is   
   to ensure that the reader knows what to expect.
3. Use of WinStyleHidden. In Paradox 9 this setting has  
   caused some people problems, often when using the 
   Project Viewer.
   However, the "bringToTop() commands should cure the 
   problems encountered, and will be acceptable to all  
   versions of Paradox for Windows. WinStyleHidden is very 
   useful for use when the invoked form has something to do 
   (e.g. setting filters) before letting the user see the  
   results.
4. The two bringToTop() commands. See #3 above.
5. The use of the wait() method for the invoked form. This 
   only returns logical True or logical False. It will 
   always return logical False if the form has stopped 
   running and formReturn() was not used to return control 
   to the invoking code. This includes cases where the form 
   crashes, is taken into design mode, and when the system 
   menu buttons are used. It is recommended that any other 
   information be returned in some other fashion, and not    
   via the formReturn() method. Your code will be much 
   cleaner, clearer, easier to read, and simpler to
   maintain this way.
6. The two comment lines indicate where you should place 
   code to react to whatever may have happened when the 
   user had the other form open. Please note that there is 
   another FAQ,

   "TIP:Recommended ways of Exchanging Information"

   available, that discusses how you should move data 
   between objects like forms, libraries, and scripts.
-------------------------------
2.2 The Invoked Form - #page2::arrive()
-------------------------------
This method should have, at least, the following code:

 bringToTop()
 show()

The bringToTop() will ensure that the form opens at the top 
of the Z-order, and the show() will ensure that it is seen 
if it was opened hidden.

#page2::arrive() 

is used because this is almost the last place that is 
visited before the form needs to be seen. Thus putting
the code for visibility here ensures that you have the 
maximum possible opportunity for other work before letting 
the user at the form
-------------------------------
2.3 The Invoked Form - #button3"::pushButton()
-------------------------------
Obviously, buttons contain a lot of code. However, for the
buttons that close the form, the code should be pretty 
minimal.

Use this code for every button:

formReturn(True)

The logical True indicates (see 2.1 above) that the form 
was closed because the user wanted it closed, not because 
it crashed, etc.


Paradox Community Newsgroups


 Feedback |  Paradox Day |  Who Uses Paradox |  I Use Paradox |  Downloads 


 The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation.
 Paradox is a registered trademark of Corel Corporation.


 Modified: 15 May 2003
 Terms of Use / Legal Disclaimer


 Copyright © 2001- 2003 Paradox Community. All rights reserved. 
 Company and product names are trademarks or registered trademarks of their respective companies. 
 Authors hold the copyrights to their own works. Please contact the author of any article for details.