Moving and Sizing a Control

To move or size a control, use the MoveWindow function. This function moves the control to the specified point in the parent window's client area and sets the control to the given width and height. The following example shows how to move and size a control:

MoveWindow(hButtonWnd, 10,10, 30,12, TRUE);

This example moves a control to the point (10, 10) in the client area and sets the width and height to 30 and 12 pixels, respectively. The value TRUE specifies that the control should be repainted after moving.

Windows automatically moves a control when it moves the parent window. A control's position is always relative to the upper-left corner of the parent's client area, so when the parent moves, the control remains fixed in the client area but moves relative to the display. Although Windows does not size a control when it sizes the parent window, it sends a WM_SIZE message to the parent to indicate the new size of the parent window. You can use this message to give the control a new size.