WM_SYSCOMMAND
wCmdType = wParam; /* command value */
xPos = LOWORD(lParam); /* horizontal position of cursor */
yPos = HIWORD(lParam); /* vertical position of cursor */
The WM_SYSCOMMAND message is sent when the user selects a command from the System menu (sometimes referred to as the Control menu) or when the user selects the Maximize button or the Minimize button.
wCmdType
Value of wParam. Specifies the type of system command requested. This parameter can be one of the following values:
Value | Meaning |
SC_CLOSE | Close the window. |
SC_HOTKEY | Activate the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate. |
SC_HSCROLL | Scroll horizontally. |
SC_KEYMENU | Retrieve a menu through a keystroke. |
SC_MAXIMIZE (or SC_ZOOM) | Maximize the window. |
SC_MINIMIZE (or SC_ICON) | Minimize the window. |
SC_MOUSEMENU | Retrieve a menu through a mouse click. |
SC_MOVE | Move the window. |
SC_NEXTWINDOW | Move to the next window. |
SC_PREVWINDOW | Move to the previous window. |
SC_RESTORE | Restore window to normal position and size. |
SC_SCREENSAVE | Execute the screen-saver application specified in the [boot] section of the SYSTEM.INI file. |
SC_SIZE | Size the window. |
SC_TASKLIST | Execute or activate the Windows Task Manager application. |
SC_VSCROLL | Scroll vertically. |
xPos
Value of the low-order word of lParam. Specifies the x-coordinate of the cursor, if a System-menu command is chosen with the mouse. Otherwise, this parameter is not used.
yPos
Value of the high-order word of lParam. Specifies the y-coordinate of the cursor, if a System-menu command is chosen with the mouse. Otherwise, this parameter is not used.
An application should return zero if it processes this message.
The DefWindowProc function carries out the System-menu request for the predefined actions specified in the preceding table.
In WM_SYSCOMMAND messages, the four low-order bits of the wCmdType parameter are used internally by Windows. When an application tests the value of wCmdType, it must combine the value 0xFFF0 with the wCmdType value by using the bitwise AND operator to obtain the correct result.
The menu items in a System menu can be modified by using the GetSystemMenu, AppendMenu, InsertMenu, and ModifyMenu functions. Applications that modify the System menu must process WM_SYSCOMMAND messages. Any WM_SYSCOMMAND messages not handled by the application must be passed to the DefWindowProc function. Any command values added by an application must be processed by the application and cannot be passed to DefWindowProc.
An application can carry out any system command at any time by passing a WM_SYSCOMMAND message to the DefWindowProc function.
Accelerator keystrokes that are defined to select items from the System menu are translated into WM_SYSCOMMAND messages; all other accelerator key strokes are translated into WM_COMMAND messages.
AppendMenu, DefWindowProc, GetSystemMenu, InsertMenu, ModifyMenu, WM_COMMAND