There are some drawbacks to discarding and reloading the grandchildren:
1. The panel callback checking EVENT_PANEL_MOVE won't run until you stop moving the panel. The callback waits until you release the mouse button to process the event. So you can't move a child out of its parent (by assigning a new parent) unless you release the mouse.
2. The panels will lose focus and may blink as you discard and reload. The movement won't appear smooth.
3. The panels will revert to their default positions from the UIR file. You'll need to read the panels position before discarding using GetPanelAttribute then restore its position after reloading.
Why is it important to assign a new parent to the grandchild? Does its behavior change based on who the parent
is? If so, how? Why not load the panels as children of the main panel? Then you could move them anywhere you want without assigning parents.
To know if a panel you moved is on top of another panel, you need to use GetPanelAttribute to read the top, height, left, and width of all the panels. Then do some simple math to determine if the top left of the moved panel is within another panel (top to top + height, left to left + width). Like in drawback 1 above, you won't know where the moved panel is until you stop moving it and release the mouse button. You could get updated into on the mouse position using ExtendedMouseEvents as the panel is moving, but to identify the panel position based on the mouse position, you need to know where on the panel title bar the mouse was first clicked.