Function Reference


_WinAPI_SetWindowPos

Changes the size, position, and Z order of a child, pop-up, or top-level window

#include <WinAPI.au3>
_WinAPI_SetWindowPos ( $hWnd, $hAfter, $iX, $iY, $iCX, $iCY, $iFlags )

Parameters

$hWnd Handle of window
$hAfter Identifies the window to precede the positioned window in the Z order. This parameter must be a
window handle or one of the following values:
    $HWND_BOTTOM - Places the window at the bottom of the Z order
    $HWND_NOTOPMOST - Places the window above all non-topmost windows
    $HWND_TOP - Places the window at the top of the Z order
    $HWND_TOPMOST - Places the window above all non-topmost windows
$iX Specifies the new position of the left side of the window
$iY Specifies the new position of the top of the window
$iCX Specifies the new width of the window, in pixels
$iCY Specifies the new height of the window, in pixels
$iFlags Specifies the window sizing and positioning flags:
    $SWP_DRAWFRAME - Draws a frame around the window
    $SWP_FRAMECHANGED - Sends a $WM_NCCALCSIZE message to the window, even if the window's size is not changed
    $SWP_HIDEWINDOW - Hides the window
    $SWP_NOACTIVATE - Does not activate the window
    $SWP_NOCOPYBITS - Discards the entire contents of the client area
    $SWP_NOMOVE - Retains the current position
    $SWP_NOOWNERZORDER - Does not change the owner window's position in the Z order
    $SWP_NOREDRAW - Does not redraw changes
    $SWP_NOREPOSITION - Same as the $SWP_NOOWNERZORDER flag
    $SWP_NOSENDCHANGING - Prevents the window from receiving $WM_WINDOWPOSCHANGING
    $SWP_NOSIZE - Retains the current size
    $SWP_NOZORDER - Retains the current Z order
    $SWP_SHOWWINDOW - Displays the window

Return Value

Success: True
Failure: False, call _WinAPI_GetLastError() to get extended error information

Remarks

Above constants require #include <AutoItConstants.au3>

See Also

Search SetWindowPos in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    ; Assign a Local variable the handle of the NotePad window
    Local $hWnd = WinGetHandle("[CLASS:Notepad]")

    ; If the window does not exists, display a message and return False.
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "", "Notepad window not found.")
        Return False
    EndIf

    ; Assign a Local variable the style of the Notepad window.
    Local $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)

    ; Remove from the window style the MAXIMIZEBOX, MINIMIZEBOX and SIZEBOX styles.
    $iStyle = BitXOR($iStyle, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX)

    ; Set the style of the window.
    _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $iStyle)

    ; Apply the style
    _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
EndFunc   ;==>Example