MoveWindow

2.x

  BOOL MoveWindow(hwnd, nLeft, nTop, nWidth, nHeight, fRepaint)    
  HWND hwnd; /* handle of window, */  
  int nLeft; /* left coordinate, */  
  int nTop; /* top coordinate, */  
  int nWidth; /* width */
  int nHeight; /* height */
  BOOL fRepaint; /* repaint flag, */  

The MoveWindow function changes the position and dimensions of a window. For top-level windows, the position and dimensions are relative to the upper-left corner of the screen. For child windows, they are relative to the upper-left corner of the parent window's client area.

Parameters

hwnd

Identifies the window to be changed.

nLeft

Specifies the new position of the left side of the window.

nTop

Specifies the new position of the top of the window.

nWidth

Specifies the new width of the window.

nHeight

Specifies the new height of the window.

fRepaint

Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a WM_PAINT message. If this parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title and scroll bars), and any part of the parent window uncovered as a result of the moved window. When this parameter is FALSE, the application must explicitly invalidate or redraw any parts of the window and parent window that must be redrawn.

Return Value

The return value is nonzero if the function is successful. Otherwise, it is zero.

Comments

The MoveWindow function sends a WM_GETMINMAXINFO message to the window being moved, giving it an opportunity to modify the default values for the largest and smallest possible windows. If the MoveWindow parameters exceed these values, they will be replaced by the minimum or maximum values specified in the WM_GETMINMAXINFO message.

Example

The following example changes the dimensions of a child window in response to a WM_SIZE message. In this example, the child window would always fill the client area of the parent window.

case WM_SIZE:
    MoveWindow(hwndChild, 0, 0, LOWORD(lParam), HIWORD(lParam),
        TRUE);
    break;

See Also

ClientToScreen, GetWindowRect, ScreenToClient, SetWindowPos