Prevent form open 
Author Message
 Prevent form open

I want to open a second form from a first and then pass
parameters to it.  No problem.  But now I want to make
sure the second form can't be opened directly.  I've tried
checking on the calling form and if there isn't one, that
the closes again, but I can't seem to figure out where to
put that code.  Even though I put a wait() in the calling
form, the called form still says there isn't a calling
form and closes.

I've seen this done before, but I've never seen the code
to do it.  What am I doing wrong?

Thanks in advance -- Jochen



Tue, 30 Jun 1998 03:00:00 GMT
 Prevent form open

Quote:
> I want to open a second form from a first and then pass
> parameters to it.  No problem.  But now I want to make
> sure the second form can't be opened directly.  I've tried
> checking on the calling form and if there isn't one, that
> the closes again, but I can't seem to figure out where to
> put that code.  Even though I put a wait() in the calling
> form, the called form still says there isn't a calling
> form and closes.

> I've seen this done before, but I've never seen the code
> to do it.  What am I doing wrong?

I think the problem is that the Wait() is executed after the
second form is done opening, and the code you want to stop the
open should go in the Open() method.  'no way there from
here...'  Instead, try testing the parameters.  That's what I
do.  If the second form doesn't recognize the parameters passed,
ya know, like if there are none, then it won't open, and this
can be done in the open method, like this:

if Params = "" then
  EventInfo.SetErrorCode(1)
  MessageStop("Error!", "This form cannot run independently...")
endif

Good Luck

Glen



Thu, 02 Jul 1998 03:00:00 GMT
 Prevent form open
Quote:

>I want to open a second form from a first and then pass
>parameters to it.  No problem.  But now I want to make
>sure the second form can't be opened directly.  I've tried
>checking on the calling form and if there isn't one, that
>the closes again, but I can't seem to figure out where to
>put that code.  Even though I put a wait() in the calling
>form, the called form still says there isn't a calling
>form and closes.

>I've seen this done before, but I've never seen the code
>to do it.  What am I doing wrong?

>Thanks in advance -- Jochen

I use the following code, in the open method of the
second form:

method Open(..whatever the parms are)
var
   f form
endvar

   if eventInfo.isPreFilter()
      ; ...
   else
      ; If the master form isn't open, then don't allow this
      ; form to open.
      if not f.attach("The Master Form") then
         MsgStop("Not a Standalone","Sorry, this form can only be"+"
                 " opened from within the \"Such and Such\" application.")
         close()
      endif
      ; other open processing
   endif
endmethod

your master form will look something like this:

method Whatever()
var
   SecondForm form
endvar
   SecondForm.open("second")
   SecondForm.SetFormParameters(x,y,z)
   SecondForm.Wait()

endmethod

with appropriate error handling, of course.

As for the CallingForm method, I found that I had to set up
a timer for it to work properly.  The code looks something like this:

; attached to OK button:
var
   iTryCount
endvar

proc CheckForCaller()
var
   f Form
endvar
   if FormCaller(f) then
      ; Shutdown processing
      FormReturn(true)
   else
      if iTryCount > 10000 then ; only wait 10 seconds
         MsgStop("Internal timeout","Can't get form caller.")
         close()
      else
         iTryCount = iTryCount + 200
         self.setTimer(200,FALSE) ; wait another 200 milleseconds
      endif
   endif
endproc

method timer(var eventInfo TimerEvent)
   CheckForCaller()
endmethod

method pushButton(...)
   iTryCount = 0
   CheckForCaller()
endmethod

Sorry about the length of this post.  Hope it helps.
Jim



Fri, 03 Jul 1998 03:00:00 GMT
 Prevent form open
: I want to open a second form from a first and then pass
: parameters to it.  No problem.  But now I want to make
: sure the second form can't be opened directly.  I've tried
: checking on the calling form and if there isn't one, that
: the closes again, but I can't seem to figure out where to
: put that code.  Even though I put a wait() in the calling
: form, the called form still says there isn't a calling
: form and closes.

: I've seen this done before, but I've never seen the code
: to do it.  What am I doing wrong?

What you need to do is use ATTACH() to see if the calling form is open.
formcaller() doesn't work unless a WAIT() is in progress.

--
=========================================================================
Kasey K. S. Chang (a guy)             | Paradox for Windows Programmer

URL> http://userwww.sfsu.edu/~kschang | X-COM Guru   General PC expert
--------------------------------------+----------------------------------
Editor of XCOM and XCOM2 UN-official Strategy Guide -- FREE!  (See URL)



Mon, 06 Jul 1998 03:00:00 GMT
 Prevent form open

Quote:

> I want to open a second form from a first and then pass
> parameters to it.  No problem.  But now I want to make
> sure the second form can't be opened directly.  I've tried
> checking on the calling form and if there isn't one, that
> the closes again, but I can't seem to figure out where to
> put that code.  Even though I put a wait() in the calling
> form, the called form still says there isn't a calling
> form and closes.

> I've seen this done before, but I've never seen the code
> to do it.  What am I doing wrong?

> Thanks in advance -- Jochen

One of the DivePlan examples does this....Use a logical Library variable
(IsCalled I think is the name used in the example), and set it to true
before calling a "secondary" form.  In all forms which must be called,
check for this library variable being set to true (open the library as
GlobalToDesktop in the open method of the form).  If the library variable
is not true, just close the secondary form.  Make sure to set the library
variable to False in the close method of all secondary forms (or set it
to false after the wait() statement in the calling form).

--
Alan Berger
SAMA-Soft Consulting, Inc.
908 560-1326

Paradox and Delphi



Tue, 07 Jul 1998 03:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Preventing Form from Opening Twice

2. Preventing a from from being opened - if already open

3. PDOX5.0 open form command Vs. PDOX7.0 open form command

4. Prevent another instance of the app from opening

5. File Open Error when I open too many time the same form

6. Preventing Login Prompt when Opening Interbase DB

7. Help: to prevent access to Oracle in Open VMS

8. how to prevent anyone from logging into an open server

9. Unwanted Open Form and Open Report Dialogs appearing

10. lookup tables prevent opening data table

11. Prevent script execution when opening a file

12. Preventing from opening second connection


 
Powered by phpBB® Forum Software