看了半天,估计你是想实现窗体的Dock功能,即是把一个窗体的停靠在另一个窗体的Pannel上,但是你的做法欠佳,推荐你直接使用Dock这个属性。
void __fastcall TConjoinDockHost::FormUnDock(TObject *Sender, TControl *Client, TWinControl *NewTarget, bool &Allow)
{
//only 2 dock clients means the host must be destroyed and
//the remaining window undocked to its old position and size.
//(Recall that OnUnDock gets called before the undocking actually occurs)
if (Client->InheritsFrom(__classid(TDockableForm))
((TDockableForm *)Client)->DockSite = true;
if ((DockClientCount == 2) && (NewTarget != (TWinControl *)&this))