Procedure to Disable Window Close Button

In the CREATE event of the window, code the following:

declare function GetSystemMenu, RemoveMenu

EQU MF_BYPOSITION$ TO 1024

hwnd = Get_Property( @window, 'HANDLE')

system_menu_hwnd = GetSystemMenu ( hwnd, 0)

rv = RemoveMenu (system_menu_hwnd, 6, MF_BYPOSITION$)

Using the handle of the window, the program gets the handle of the system menu (the menu with the Close menu item in it) by calling GetSystemMenu(). Then the Close menu item, the 6th item in the menu, is removed by calling RemoveMenu().

Adding DLL Declarations

The code above will not run until the declarations for GetSystemMenu() and RemoveMenu() have been added. To add the declarations, do the following:

USER32
ULONG STDCALL RemoveMenu ( HANDLE, ULONG, ULONG)
//...other declarations in USER32 to follow...

RUN DECLARE_FCNS 'DLL_APICALLS_USER32'

The window should run, displaying as shown in the previous topic.