I found a way to solve this problem, its an addition to the global-shared code (so use their code and edit that, there will be a bit unused code but you can delete that manually):
declare two extra preprosessors:
&GLOBAL-DEFINE MF_GRAYED 1
&GLOBAL-DEFINE MF_ENABLED 0
and declare another function:
PROCEDURE EnableMenuItem EXTERNAL "user32":
DEFINE INPUT PARAMETER hMenu AS LONG.
DEFINE INPUT PARAMETER uIDEnableItem AS LONG.
DEFINE INPUT PARAMETER uEnable AS LONG.
DEFINE RETURN PARAMETER iRetCode AS LONG.
END.
then you cold use this function to disable:
FUNCTION XPDisableMenuItem RETURNS LOGICAL
( ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
define var hSysMenu as int no-undo.
define var hParent as int no-undo.
define var hInstance as int no-undo.
define var iRetCode as int no-undo.
define var iCnt as int no-undo.
run GetParent(input {&window-name}:hWnd,
output hParent).
/* Get handle to our the window's system menu (Restore, Maximize, Move, close etc.) */
run GetSystemMenu(input hParent,
input 0,
output hSysMenu).
if hSysMenu <> 0 then
do:
/* Get System menu's menu count */
run GetMenuItemCount(input hSysMenu,
output iCnt).
IF iCnt <> 0 then
do:
RUN EnableMenuItem (input hSysMenu,input iCnt - 1,INPUT {&MF_BYPOSITION} + {&MF_GRAYED},OUTPUT iRetCode).
/* Force caption bar's refresh which will disable the window close ("X") button */
run DrawMenuBar(input hParent,output iRetCode).
end. /* if iCnt <> 0... */
end. /* if hSysMenu <> 0... */
RETURN FALSE. /* Function return value. */
END FUNCTION.
And this one to enable
FUNCTION XPEnableMenuItem RETURNS LOGICAL
( ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
define var hSysMenu as int no-undo.
define var hParent as int no-undo.
define var hInstance as int no-undo.
define var iRetCode as int no-undo.
define var iCnt as int no-undo.
run GetParent(input {&window-name}:hWnd,
output hParent).
/* Get handle to our the window's system menu (Restore, Maximize, Move, close etc.) */
run GetSystemMenu(input hParent,
input 0,
output hSysMenu).
if hSysMenu <> 0 then
do:
/* Get System menu's menu count */
run GetMenuItemCount(input hSysMenu,
output iCnt).
IF iCnt <> 0 then
do:
RUN EnableMenuItem (input hSysMenu,input iCnt - 1,INPUT {&MF_BYPOSITION} + {&MF_ENABLED},OUTPUT iRetCode).
/* Force caption bar's refresh which will disable the window close ("X") button */
run DrawMenuBar(input hParent,output iRetCode).
end. /* if iCnt <> 0... */
end. /* if hSysMenu <> 0... */
RETURN FALSE. /* Function return value. */
END FUNCTION.