System Menu Close Handling Under Windows

The Windows system menu has a Close item. Normally, if the user clicks this entry, the run-time system performs a normal shut down. The Close option can be controlled with the QUIT_MODE configuration variable or permanently disabled when the window is created with the NO-CLOSE phrase.

A QUIT_MODE setting of zero or less is handled directly by the runtime system. A positive QUIT_MODE setting allows your program to manage the close action instead. When a positive value is used, the Close item becomes a standard menu item with an ID equal to the value of QUIT-MODE. You may then handle the Close item just like any other menu item.

For example, if you set QUIT_MODE to 100, your program will receive exception value 100 when the user selects the Close item. If you wanted to call a special shutdown program when the user selects Close, you can assign the Close action to a hot-key program. For example:

MENU-ITEM  Hot-Key="shutdown"  100

In this example, the program shutdown might pop up a small window to confirm that the user wants to exit and, if so, execute a STOP RUN.

When the NO-CLOSE phrase is specified in a Format 11 or 12 DISPLAY WINDOW statement, the window's Close menu option is permanently disabled. The option can be applied only when the window is created and its effects cannot be reversed. The NO-CLOSE option takes precedence over other settings, including the setting of the QUIT_MODE configuration variable.