# Function Reference

# _WinAPI_SetParent

Changes the parent window of the specified child window

#include <WinAPISysWin.au3>
_WinAPI_SetParent ( $hWndChild, $hWndParent )

## Parameters

$hWndChild | Window handle of child window
$hWndParent | Handle to the new parent window. If 0, the desktop window becomes the new parent window.

## Return Value

Success: | A handle to the previous parent window
Failure: | 0, call _WinAPI_GetLastError() to get extended error information

## Remarks

An application can use the SetParent function to set the parent window of a pop-up, overlapped, or child
window. The new parent window and the child window must belong to the same application.

## See Also

Search SetParent in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <WinAPISysWin.au3>
    #include <WindowsStylesConstants.au3>

    Local $hParent = WinGetHandle('[CLASS:Progman;TITLE:Program Manager]')

    Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400, 100, 100, -1, $WS_EX_TOOLWINDOW)

    ; Attach window to the desktop (always on bottom)
    _WinAPI_SetParent($hForm, $hParent)

    GUISetState(@SW_SHOWNOACTIVATE)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE