Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
SetParent moves a window from having one parent window to another. If needed, the window itself moves so it can be "inside" its new parent. If successful, the function returns the handle of the moved window's former parent. If it fails, it will instead return 0.
' Move a button from Framw1 to Frame2
oldhwnd = SetParent(Command1.hWnd, Frame2.hWnd) ' button now inside Frame2
Debug.Print Frame1.hWnd; oldhwnd ' should be the same
Related Call: GetParent
Category: Windows
Back to the index.