To be consistent with Human Interface Guidelines (HIG) of both Mac and Window, a click in the Close Box should close the window of the root process. However, by default, in 4D if the user is in a Detail form, by default, clicking the Close Box does the same as clicking the Cancel button, it close the Detail form, returning the user to the List form. To exit the process the user has to click the Close Box a second time.
The instuctions and code below will give the user the default HIG Close Box behavior of completely closing all form windows, Detail and List, when the Close Box is clicked.
1) In both the List and Detail forms enable the Close Box form event property.
2) In the form, or appropriate object, method of the list form include the following code:
Case of :(Form event = On Close Box) CANCEL :(Form event = On Load) C_BOOLEAN(CloseListForm_B) :(Form event = On Double Clicked) If (Not(Locked([MyTable]))) CloseListForm_B:=False MODIFY RECORD([MyTable]) // Modify the record UNLOAD RECORD([MyTable]) If (CloseListForm_B) CANCEL // Close the List form as well End if Else ALERT("The record is currently in use.") End if End case |
3) In the form method of the Detail form place the following code:
Case of :(Form event = On Close Box) CloseListForm_B:=True CANCEL End case |
Now when the user clickes the Close box of the Detail form both forms will cancel and the process will be fully closed.