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

Go To Open Form 1

Status
Not open for further replies.

bobsmallwood

Programmer
Aug 9, 2001
38
US
Is there code that can be attached to a button that will "go to" a form if it is already open and, if not, open it?
 
You could keep track of when a form is opened or closed.
Or you could use eNumFormNames to see what is already opened. See eNumFormNames help file example.

If the form you want is on the list you can use Attach to take control of the form and bring it to top of all other forms.


 
bobsmallwood,

Just to add to Joe's thoughts, here's one way to do it:

Code:
method pushButton(var eventInfo Event)
var
   frm  Form
endVar

const
   FORM_TITLE = "Form : vendors.fsl"
   FORM_FILE  = "vendors.fsl"
endConst

   if not frm.attach( FORM_TITLE ) then
      if not frm.open( FORM_FILE ) then
         errorShow( "Can't Open " + FORM_TITLE,
                    "Use [>>] for details..." )
      endIf
   endIf

   if frm.isAssigned() then
      frm.show()
      frm.bringToTop()
   endIf

endMethod

Now, there are some considerations to keep in mind:

1. The form title must exactly match, which is why it's a good idea to specify custom titles for your Paradox forms using Format | Windows Style. (If you get multiple copies of your form, check the title carefully; Paradox sometimes adds spaces for readability.)

2. I used both show() and bringToTop() to work around some problems with z-order that were very common in older versions of Windows. I don't remember the exact problems, but using both command together has worked reliably for several versions of Paradox and Windows. It's a habit I got into with Paradox 5 and t still seems to work fine.

3. You'll note I used constants for the form's title and its filename. This is to make it easier to customize or to convert to a custom method in a library, which I'll leave as an exercise for the moment. :)

4. If you want to try this out, put it on a button on one of the forms provided with the Paradox samples.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top