Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing Control-Box property in runtime

Status
Not open for further replies.

AhmetSinav

IS-IT--Management
Mar 28, 2006
25
TR
Hi,
How can i change the c-win control-box property to false in runtime.
Best Regards.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top