Triggering a procedure when a window is closed


#1

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


#2

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.


#3

Hi Michael,

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


#4

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.


#5

Sorry, no, not at this time.


#6

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”)
+":",array(import(),2,":"),"")})
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"
theFormWindows=theFormWindow+¶+array(info(“formname”),2,”:")
endif
// updates the variable with new form name

StartTimer checkForms
code:
local currentForms,closedForm
currentForms =arrayfilter(info(“formwindows”),¶,{?(import() beginswith info(“databasename”)
+":",array(import(),2,":"),"")})
arraystrip currentForms,¶
If arraydifference(theFormNames, currentForms,¶,)=""
nop
Else
closedForm=arraydifference(theFormNames, currentForms,¶,)
// do things depending upon what form was closed
Endif
// 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:


#7

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.