HMENU GetSystemMenu(hwnd, fRevert) | |||||
HWND hwnd; | /* handle of window to own the System menu | */ | |||
BOOL fRevert; | /* reset flag, */ |
The GetSystemMenu function allows the application to access the System menu for copying and modification.
hwnd
Identifies the window that will own a copy of the System menu.
fRevert
Specifies the action to be taken. If this parameter is FALSE, the GetSystemMenu function returns a handle of a copy of the System menu currently in use. This copy is initially identical to the System menu, but can be modified.
If the parameter is TRUE, GetSystemMenu resets the System menu back to the Windows default state. The previous System menu, if any, is destroyed. The return value is undefined in this case.
The return value is the handle of a copy of the System menu, if the fRevert parameter is FALSE. If fRevert is TRUE, the return value is undefined.
Any window that does not use the GetSystemMenu function to make its own copy of the System menu receives the standard System menu.
The handle that GetSystemMenu returns can be used with the AppendMenu, InsertMenu, or ModifyMenu function to change the System menu. The System menu initially contains items identified by various identifier values such as SC_CLOSE, SC_MOVE, and SC_SIZE. Menu items on the System menu send WM_SYSCOMMAND messages. All predefined System-menu items have identifier numbers greater than 0xF000. If an application adds commands to the System menu, it should use identifier numbers less than 0xF000.
Windows automatically grays (dims) items on the standard System menu, depending on the situation. The application can carry out its own checking or graying by responding to the WM_INITMENU message, which is sent before any menu is displayed.
The following example appends the About item to the System menu:
HMENU hmenu;
hmenu = GetSystemMenu(hwnd, FALSE);
AppendMenu(hmenu, MF_SEPARATOR, 0, (LPSTR) NULL);
AppendMenu(hmenu, MF_STRING, IDM_ABOUT, "About...");