In this section:
ClearWin+ programs may create a number of windows, some of which might be open at the same time. A ClearWin+ program terminates when both a) the END point of the program (or its equivalent) is reached, and b) all windows created by the program have been closed by the user.
Normally the user is provided with a number of ways to close a window. There is usually a system menu with a 'Close' item (Alt+F4) at the top left of a window. Selecting this item is equivalent to clicking on the close box at the top right of a window. The programmer can use %cc (Control Closure) with a call-back function to trap this event.
The programmer can also add an 'EXIT' item to a %mn (Menu) menu. This item will either be linked to a call-back function provided in the program or to the standard 'EXIT' call-back.
Other exit routes can be provided via buttons (using for example %bt (Button) or %tt (Textual Toolbar)):
a) When you click on the button that has no call-back function attached, the parent window will close. If there is only one window open, the effect is the same as if the standard 'EXIT' call-back were attached to the button.
b) If there is no call-back function attached to a button and the associated window has been created within a call-back function, then the window will close. The affect on the window's parent will depend on the value returned by the call-back (see Call-back functions). A zero return will close the window's parent. The same is true for any call-back, not just those attached to buttons.
Another approach to window closure is to attach a control variable to a window. When a window (or dialog) is created, by default it will be equivalent to a modal dialog box. A modal dialog box is one that must be closed before other windows in the same application can be accessed. Any code that follows the winio@ calls for a particular modal dialog box, will not be processed until the user closes the dialog.
If you want more than one window to be accessible (the equivalent of a modeless dialog box) then you can use %lw (Leave Window Open) (see Leave window open) to leave a window open and to attach a control variable to the window. The presence of %lw causes any code that follows the winio@ calls for a particular window to be processed immediately. ClearWin+ sets the value of a %lw control variable to -1 (minus one). If the control variable is subsequently set a non-negative value, the window will close when that variable is updated (see below).
Notes
1. %lw (Leave Window Open) is used together with %fr (MDI Frame) and %aw (Attach MDI Child Window) to create a multi-document interface.
2. %cv (Control Variable) also provides a control variable for use with %aw (Attach MDI Child Window) but in this case the window will be a child window and will not be left open.