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:

code format="bb4w" ON CLOSE RETURN code 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:

code format="bb4w" SC_CLOSE = &F060 SYS "GetSystemMenu", @hwnd%, 0 TO sysmenu% SYS "EnableMenuItem", sysmenu%, SC_CLOSE, 1 code When you want to enable the button again execute the following code:

code format="bb4w" SC_CLOSE = &F060 SYS "GetSystemMenu", @hwnd%, 0 TO sysmenu% SYS "EnableMenuItem", sysmenu%, SC_CLOSE, 0 code Note that whereas also causes **Alt+F4** to be ignored, disabling the close button doesn't, and this alternative means of closing the window remains available.