we can make it via following code.
{windows.i}
FUNCTION DisableWindowClose RETURNS LOGICAL
( /* parameter-definitions */ ) :
/*---------------------------------------
Purpose:
Notes:
-----------------------------------------*/
DEFINE VARIABLE hSysMenu AS INTEGER NO-UNDO.
DEFINE VARIABLE hParent AS INTEGER NO-UNDO.
DEFINE VARIABLE hInstance AS INTEGER NO-UNDO.
DEFINE VARIABLE iRetCode AS INTEGER NO-UNDO.
DEFINE VARIABLE iCnt AS INTEGER NO-UNDO.
RUN GetParent IN hpApi(INPUT {&window-NAME}:HWND,
OUTPUT hParent).
/* Get handle to the window's system menu
(Restore, Maximize, Move, close etc.) */
RUN GetSystemMenu IN hpApi(INPUT hParent,
INPUT 0,
OUTPUT hSysMenu).
IF hSysMenu NE 0 THEN
DO:
/* Get System menu's menu count */
RUN GetMenuItemCount IN hpApi(INPUT hSysMenu,
OUTPUT iCnt).
IF iCnt NE 0 THEN
DO:
/* Menu count is based on 0 (0, 1, 2, 3...) */
/* remove the "close option" */
RUN RemoveMenu IN hpApi(INPUT hSysMenu,
INPUT iCnt - 1,
INPUT {&MF_BYPOSITION} + {&MF_REMOVE},
OUTPUT iRetCode).
/* remove the seperator */
RUN RemoveMenu IN hpApi(INPUT hSysMenu,
INPUT iCnt - 2,
INPUT {&MF_BYPOSITION} + {&MF_REMOVE},
OUTPUT iRetCode).
/* Force caption bar's refresh which
will disable the window close ("X") button */
RUN DrawMenuBar IN hpApi(INPUT hParent,
OUTPUT iRetCode).
{&window-NAME}:TITLE = "Try to close me!".
END. /* if iCnt NE 0... */
END. /* if hSysMenu NE 0... */
RETURN FALSE. /* Function return value. */
END FUNCTION.