Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This message is sent to a window when the user chooses a command from the windowmenu, formerly known as the system or control menu, or when the user chooses the maximize button or the minimize button.

Syntax

WM_SYSCOMMAND 
uCmdType = 
wParam; 

xPos = LOWORD(
lParam); 

yPos = HIWORD(
lParam);

Parameters

uCmdType

Specifies the type of system command requested. It is one of the following values.

Value Description

SC_CLOSE

Closes the window.

SC_KEYMENU

Retrieves the windowmenu as a result of a keystroke.

xPos

Specifies the horizontal position of the cursor, in screen coordinates, if a windowmenu command is chosen with the mouse. Otherwise, the xPosparameter is not used.

yPos

Specifies the vertical position of the cursor, in screen coordinates, if a windowmenu command is chosen with the mouse. This parameter is –1 if the command is chosen using a system accelerator, or zero if using a mnemonic.

Return Value

An application should return zero if it processes this message.

Remarks

The DefWindowProcfunction carries out the windowmenu request for the predefined actions specified in the previous table.

In WM_SYSCOMMAND messages, the four low-order bits of the uCmdTypeparameter are used internally by the system. To obtain the correct result when testing the value of uCmdType, an application must combine the value 0xFFF0 with the uCmdTypevalue by using the bitwise ANDoperator.

The menu items in a windowmenu can be modified by using the GetSystemMenu, AppendMenu, and InsertMenufunctions. Applications that modify the windowmenu must process WM_SYSCOMMAND messages.

An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to DefWindowProc. Any WM_SYSCOMMAND messages not handled by the application must be passed to DefWindowProc. Any command values added by an application must be processed by the application and cannot be passed to DefWindowProc.

Accelerator keys that are defined to choose items from the windowmenu are translated into WM_SYSCOMMAND messages; all other accelerator keystrokes are translated into WM_COMMANDmessages.

Requirements

Header winuser.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also