//--------------------------------------------------------------------------- #include #pragma hdrstop #include "PenAndNaviConjoinhost_F.h" #include "PenAndNaviDock_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TPenAndNaviConjoinhostForm *PenAndNaviConjoinhostForm; //--------------------------------------------------------------------------- __fastcall TPenAndNaviConjoinhostForm::TPenAndNaviConjoinhostForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::DoFloat(TControl* AControl) { // Float the control with its original size. TPoint TopLeft = AControl->ClientToScreen(Point(0, 0)); TPoint BottomRight = AControl->ClientToScreen(Point(AControl->UndockWidth, AControl->UndockHeight)); AControl->ManualFloat(TRect(TopLeft, BottomRight)); } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::UpdateCaption(TControl* Exclude) { int I; // If a dockable form is undocking, it will pass itself in as Exclude // because even it hasn't actually been taken out of the DockClient array // at this point. Caption = ""; for (I = 0; I < DockClientCount; I++) if (DockClients[I]->Visible && (DockClients[I] != Exclude)) Caption = Caption + static_cast(DockClients[I])->Caption + " "; } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::FormClose(TObject *Sender, TCloseAction &Action) { if (DockClientCount == 1) { DoFloat(DockClients[0]); Action = caFree; } else Action = caHide; } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::FormDockDrop(TObject *Sender, TDragDockObject *Source, int X, int Y) { UpdateCaption(NULL); DockManager->ResetBounds(true); // Force DockManager to redraw it's clients. } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::FormDockOver(TObject *Sender, TDragDockObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = (dynamic_cast(Source->Control) != NULL); } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::FormGetSiteInfo(TObject *Sender, TControl *DockClient, TRect &InfluenceRect, TPoint &MousePos, bool &CanDock) { CanDock = (dynamic_cast(DockClient) != NULL); } //--------------------------------------------------------------------------- void __fastcall TPenAndNaviConjoinhostForm::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 (dynamic_cast(Client) != NULL) (static_cast(Client))->DockSite = true; if ((DockClientCount == 2) && (NewTarget != this)) PostMessage(this->Handle, WM_CLOSE, 0, 0); UpdateCaption(Client); } //---------------------------------------------------------------------------