# CodeGuru Technical FAQs > CodeGuru Individual Visual Basic FAQs >  SetParent

## TT(n)

SetParent changes the parent window of the specified child window.  Can use with NULL constant in hWndNewParent to set the desktop as the new parent



```
    Private Declare Function apiSetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Int32, ByVal hWndNewParent As Int32) As Int32
    Const HWND_DESKTOP As Int32 = 0

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        apiSetParent(Button1.Handle.ToInt32, HWND_DESKTOP)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("I can't find my mommy!")
        apiSetParent(Button1.Handle.ToInt32, Me.Handle.ToInt32)
    End Sub
```

----------

