Subject Re: Form closing when idle
From Mervyn Bick <invalid@invalid.invalid>
Date Mon, 14 Jun 2021 09:18:30 +0200
Newsgroups dbase.getting-started

On 2021/06/13 18:43, Mustansir Ghor wrote:
> Dear Mervyn sir
>
> I use this routine and thanks to you. But I wish to know if there is possibility for me to use in the scenario where I have main form attached to it is menu. The Menu opens other forms in readmodal. So can I set this routine in the main form where by when it closes, it will also close the opened readmodal form along with it.
>

You can use the main form's form_canClose() event handler to check if
one of your subsidiary readmodal forms is open.  If it's open then close
it.  Once the open readmodal form has been closed the form_canClose
event handler will allow the main form to be closed.

findInstance() takes a specific form's classname as the parameter so you
will need to test for all the subsidiary forms even though only one can
be open at a time


  function form_canClose()
     local f
     f = findinstance("Form1Form")
     if not empty(f)
        f.close()
        f := findinstance("Form1Form",
     endif

     f = findinstance("Form2Form")
     if not empty(f)
        f.close()
        f := findinstance("Form1Form",
     endif
     //repeat for all forms which may be open
     return true


Mervyn.