Triggering a procedure when a window is closed

Is there a way to trigger a procedure when a form window is closed?

You could use the Action menu if you are in the data sheet or you can click on the Run button in the procedure itself.

Hi Michael,

I was hoping for something automatic like .CloseWindow automatic procedure.

Sorry - your post was ambiguous and I chose the wrong option.

I don’t believe there is such an auto procedure. I would have on the form a Save & close button whose associated procedure closed the form and did whatever else it was that you wanted done.

Sorry, no, not at this time.

Well, Jim is certainly correct and there is no easy way to do this, but…let’s see. Here is a scheme using a timer running every second that compares a list of the currently open forms with the previous list of open forms. It also makes use of the info(“formevent”) to catch the opening of any new form and adding it to the list of current forms. Here is the basic scheme which I have not fleshed out so it is mainly hypothetical.

.Initialize Procedure
define fileglobal theFormWindows=info(“formwindows”)
theFormWindows=arrayfilter(info(“formwindows”),¶,{?(import() beginswith info(“databasename”)
arraydeduplicate arraystrip(theFormWindows,¶),theFormWindows,¶
// filtered for only current db form names & removes any duplicate names that might have
been included when starting the database

Form Event Procedure (used for every form)
If info(“formevent”) match “open"
// updates the variable with new form name

StartTimer checkForms
local currentForms,closedForm
currentForms =arrayfilter(info(“formwindows”),¶,{?(import() beginswith info(“databasename”)
arraystrip currentForms,¶
If arraydifference(theFormNames, currentForms,¶,)=""
closedForm=arraydifference(theFormNames, currentForms,¶,)
// do things depending upon what form was closed
// checks to see if any form have been closed & determines which one

Rather involved but it is possible and I know that since I used a variation of this to control the the floating toolbar in my Design Sheet project. Up to you if it is worth the effort to implement.:innocent:

Thank you Gary, I will have to ponder that one. I think it will depend on the availability of Panorama X Server, when that is available I won’t need to track windows. I think I can wait until Christmas… :slight_smile:

I just read Jims response to the server question. Maybe I will use this. As you know, there is almost always a way to get there with Panorama.