The Window Close Button (sometimes called the X button) is a handy way to close a window, as is clicking on the System Menu and selecting the Close menu item.  

However, there may be occasions when you, the application developer, do not want the user to close a window in that way.  Instead, you want the user to click the Close button and run the code associated with its CLICK event, because the application requires specific processing to occur.   This topic explains how to call the Windows API functions GetSystemMenu() and RemoveMenu() to disable the Window Close button.  The window displays as shown below:

Note how the X button is disabled.  In addition, the Close menu item is disabled, as shown below:

The user must click your Close Window button to close the window.

The next topic explains how to make this happen.

 

  • No labels