截取WM_SYSCOMMAND消息。 该消息参数为: uCmdType = wParam; // type of system command requested xPos = LOWORD(lParam); // horizontal postion, in screen coordinates yPos = HIWORD(lParam); // vertical postion, in screen coordinates 其 中 uCmdType表 示 用 户 的 选 择 : SC_CLOSE Closes the window. SC_CONTEXTHELP Changes the cursor to a question with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message. SC_DEFAULT Selects the default item; the user double-clicked the System menu. SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate. SC_HSCROLL Scrolls horizontally. SC_KEYMENU Retrieves the System menu as a result of a keystroke. SC_MAXIMIZE (or SC_ZOOM) Maximizes the window. SC_MINIMIZE (or SC_ICON) Minimizes the window. SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer. SC_MOUSEMENU Retrieves the System menu as a result of a mouse click. SC_MOVE Moves the window. SC_NEXTWINDOW Moves to the next window. SC_PREVWINDOW Moves to the previous window. SC_RESTORE Restores the window to its normal position and size. SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file. SC_SIZE Sizes the window. SC_TASKLIST Executes or activates Windows Task Manager. SC_VSCROLL Scrolls vertically.
该消息参数为:
uCmdType = wParam; // type of system command requested
xPos = LOWORD(lParam); // horizontal postion, in screen coordinates
yPos = HIWORD(lParam); // vertical postion, in screen coordinates
其 中 uCmdType表 示 用 户 的 选 择 :
SC_CLOSE Closes the window.
SC_CONTEXTHELP Changes the cursor to a question with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message.
SC_DEFAULT Selects the default item; the user double-clicked the System menu.
SC_HOTKEY Activates the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
SC_HSCROLL Scrolls horizontally.
SC_KEYMENU Retrieves the System menu as a result of a keystroke.
SC_MAXIMIZE (or SC_ZOOM) Maximizes the window.
SC_MINIMIZE (or SC_ICON) Minimizes the window.
SC_MONITORPOWER Windows 95 only: Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.
SC_MOUSEMENU Retrieves the System menu as a result of a mouse click.
SC_MOVE Moves the window.
SC_NEXTWINDOW Moves to the next window.
SC_PREVWINDOW Moves to the previous window.
SC_RESTORE Restores the window to its normal position and size.
SC_SCREENSAVE Executes the screen saver application specified in the [boot] section of the SYSTEM.INI file.
SC_SIZE Sizes the window.
SC_TASKLIST Executes or activates Windows Task Manager.
SC_VSCROLL Scrolls vertically.
窗口的最大化、最小化时一般会触发:WM_GETMINMAXINFO,WM_SIZE,WM_SIZING等消息
窗口的关闭正常情况下会触发:WM_DESTROY
当然你完全有权力修改促发它们的时机,所以以上只是一般情况;2)如何判断这些消息是否产生:
一般情况下是在消息处理过程中进行判断,如:
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
// 响应代码
break;
case WM_GETMINMAXINFO: // lParam返回一个指向MINMAXINFO结构的指针
// 响应代码
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
窗口的最大化、最小化时一般会触发:WM_SYSCOMMAND,WM_GETMINMAXINFO,WM_SIZE,WM_SIZING等消息
窗口的关闭正常情况下会触发:WM_DESTROY
当然你完全有权力修改促发它们的时机,所以以上只是一般情况;2)如何判断这些消息是否产生:
一般情况下是在消息处理过程中进行判断,如:
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
// 响应代码
break;
case WM_GETMINMAXINFO: // lParam返回一个指向MINMAXINFO结构的指针
// 响应代码
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}