Kbase 15201: How to Remove/Enable/Disable System Menu Items in Windows
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Remove/Enable/Disable System Menu Items in Windows
The following code example shows how to remove menu items
from the "System Menu" of a window in Microsoft Windows.
This code will work for any Progress Version 7 or Version 8 16-bit
release running under Windows 3.X, 95, or NT.
Please keep in mind that the list of items which shows up
in the "System Menu" is numbered based on zero (0).
Also, you must remove menu items in reverse order (i.e.
highest numbered item gets removed first).
PROCEDURE GetParent EXTERNAL "USER.EXE":
DEFINE INPUT PARAMETER WindowHandle AS SHORT.
DEFINE RETURN PARAMETER ParentWindowHandle AS SHORT.
END PROCEDURE.
PROCEDURE GetSystemMenu EXTERNAL "USER.EXE":
DEFINE INPUT PARAMETER WindowHandle AS SHORT.
DEFINE INPUT PARAMETER RevertFlag AS SHORT.
DEFINE RETURN PARAMETER SystemMenuHandle AS SHORT.
END PROCEDURE.
PROCEDURE RemoveMenu EXTERNAL "USER.EXE":
DEFINE INPUT PARAMETER SystemMenuHandle AS SHORT.
DEFINE INPUT PARAMETER MenuPosition AS SHORT.
DEFINE INPUT PARAMETER MenuFlags AS SHORT.
DEFINE RETURN PARAMETER Result AS SHORT.
END PROCEDURE.
PROCEDURE EnableMenuItem EXTERNAL "USER.EXE":
DEFINE INPUT PARAMETER SystemMenuHandle AS SHORT.
DEFINE INPUT PARAMETER MenuPosition AS SHORT.
DEFINE INPUT PARAMETER MenuFlags AS SHORT.
DEFINE RETURN PARAMETER Result AS SHORT.
END PROCEDURE.
DEFINE VARIABLE TheResult AS INTEGER NO-UNDO.
DEFINE VARIABLE TheSystemMenuHandle AS INTEGER NO-UNDO.
DEFINE VARIABLE TheParentHandle AS INTEGER NO-UNDO.
RUN GetParent (INPUT {&WINDOW-NAME}:HWND,
OUTPUT TheParentHandle).
RUN GetSystemMenu (INPUT TheParentHandle,
INPUT 0,
OUTPUT TheSystemMenuHandle).
RUN RemoveMenu (INPUT TheSystemMenuHandle,
INPUT 4, /* Menu # for Maximize */
INPUT 1024,
OUTPUT TheResult).
RUN RemoveMenu (INPUT TheSystemMenuHandle,
INPUT 3, /* Menu # for Minimize */
INPUT 1024,
OUTPUT TheResult).
The following RUN statement will DISABLE an item in the system menu:
RUN EnableMenuItem (INPUT TheSystemMenuHandle,
INPUT 3, /* Menu # for Minimize */
INPUT 1026,
OUTPUT TheResult).
The following RUN statement will ENABLE an item in the system menu:
RUN EnableMenuItem (INPUT TheSystemMenuHandle,
INPUT 3, /* Menu # for Minimize */
INPUT 1024,
OUTPUT TheResult).
The following RUN statement will GREY-OUT an item in the system menu:
RUN EnableMenuItem (INPUT TheSystemMenuHandle,
INPUT 3, /* Menu # for Minimize */
INPUT 1025,
OUTPUT TheResult).
Progress Software Technical Support Note # 15201