User Tools

Site Tools


Command disabled: register
disabling_20the_20close_20button

Disabling the close button

by Richard Russell, August 2008

It is easy enough to make the close button (in the top-right corner of the window) ineffective, by executing the following statement:

        ON CLOSE RETURN

This results in the button being ignored. However there may be occasions when you actually want to disable the close button, and indicate that it is disabled by it being 'greyed out'. You can do that as follows:

        SC_CLOSE = &F060
        SYS "GetSystemMenu", @hwnd%, 0 TO sysmenu%
        SYS "EnableMenuItem", sysmenu%, SC_CLOSE, 1

When you want to enable the button again execute the following code:

        SC_CLOSE = &F060
        SYS "GetSystemMenu", @hwnd%, 0 TO sysmenu%
        SYS "EnableMenuItem", sysmenu%, SC_CLOSE, 0

Note that whereas “ON CLOSE RETURN” also causes Alt+F4 to be ignored, disabling the close button doesn't, and this alternative means of closing the window remains available.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
disabling_20the_20close_20button.txt · Last modified: 2018/04/16 14:48 by richardrussell