Window sizing code

Started by sukishan, Jul 12, 2009, 05:34 PM

Previous topic - Next topic

sukishan

Window sizing

WM_SIZE: When using an application, one of the actions a user can perform on a window is to change its size, provided the window allows this. Also, from time to time, if the window allows it, the user can minimize, maximize, or restore a window. Whenever any of these actions occur, the operating system must keep track of the size of a window. When the size of a window has changed, the window sends the ON_WM_SIZE message. Its syntax is:

afx_msg void OnSize(UINT nType, int cx, int cy);The nType argument specifies what type of action to take. It can have one of the following values:

SIZE_MINIMIZED: The window has been minimized.
SIZE_MAXIMIZED: The window has been maximized.
SIZE_RESTORED: The window has been restored from being maximized or minimized.
SIZE_MAXHIDE: Another window, other than this one, has been maximized.
SIZE_MAXSHOW: Another window, other than this one, has been restored from being maximized or minimized.
The cx argument specifies the new width of the client area of the window.

The cy argument specifies the new height of the client area of the window.

To use this message, you should first call its implementation in the parent class before implementing the behavior you want. This can be done as follows:

void CAnyWindow::OnSize(UINT nType, int cx, int cy)
{
    CParentClass::OnSize(nType, cx, cy);
   
    // TODO: Add your message handler code here
}WM_SIZING: While the user is changing the size of a window, a message called ON_WM_SIZING is being sent. Its syntax is:

afx_msg void OnSizing(UINT nSide, LPRECT lpRect);When a user is resizing a window, he or she typically drags one of the borders or corners on a direction of his or her choice. The first argument, nSize, indicates what edge is being moved when resizing the window. It can have one of the following values:

WMSZ_BOTTOM: Bottom edge
WMSZ_BOTTOMLEFT: Bottom-left corner
WMSZ_BOTTOMRIGHT: Bottom-right corner
WMSZ_LEFT: Left edge
WMSZ_RIGHT: Right edge
WMSZ_TOP: Top edge
WMSZ_TOPLEFT: Top-left corner
WMSZ_TOPRIGHT: Top-right corner
A good beginning makes a good ending