Kbase 17555: How to Call WIN32 API Function: GetSystemMenu
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to Call WIN32 API Function: GetSystemMenu
DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.
INTRODUCTION:
=============
The following code sample shows how to call the Win32 API function
called GetSystemMenu. This function retrieves a handle to the system
menu. The system menu is the pop-up menu that is displayed when you
click the small icon at the top left corner of the window. An
application can add items to the system menu and remove items from the
system menu using menu modification functions such as AppendMenu()
and InsertMenu().
Passing a one (1) as the second parameter to this call will replace
the existing system menu with a normal default system menu. Passing
a zero (0) as the second parameter will retrieve a handle to the
system menu.
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE hdlParent AS INTEGER NO-UNDO.
DEFINE VARIABLE hdlMenu AS INTEGER NO-UNDO.
PROCEDURE GetParent EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER hdlToWindow AS LONG.
DEFINE RETURN PARAMETER hdlToParentWindow AS LONG.
END PROCEDURE.
PROCEDURE GetSystemMenu EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER hdlToWindow AS LONG.
DEFINE INPUT PARAMETER logRevertFlag AS LONG.
DEFINE RETURN PARAMETER hdlToSystemMenu AS LONG.
END PROCEDURE.
RUN GetParent (DEFAULT-WINDOW:HWND, OUTPUT hdlParent).
IF hdlParent = 0 THEN
DO:
MESSAGE "Can't Get Parent Window Handle" VIEW-AS ALERT-BOX.
RETURN.
END.
RUN GetSystemMenu (hdlParent, 1, OUTPUT hdlMenu).
/* If second parameter to GetSystemMenu call is 0 then hdlMenu */
/* contains the handle to the system menu otherwise hdlMenu */
/* will contain NULL. */
IF hdlMenu = 0 THEN
MESSAGE "System Menu Was Rebuilt From Scratch" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "System Menu Handle Was Retrieved" VIEW-AS ALERT-BOX.
Progress Software Technical Support Note # 17555