which I think should work. However, if the panel is floating, there appears to be a problem, in that as far as I can tell the floating window containing the panel (the wxFloatingPane) never gets destroyed.

What seems to happen is DetachPane calls m_panes.RemoveAt() which removes it from the list of panes. This prevents the Update routine doing what happens when (say) Float() is turned off, and doing a reparent to the main frame and destroying the wxFloatingPane.

I think DetachPane() should be checking for m_panes.Item(i).p_frame and if it is non-null, doing the reparent and destroy (as per Update()) before it removes it from the m_panes array, because Update() will never get to do this afterwards.