RAD Studio VCL Reference
|
Specifies the rectangle on which the control is docked if released.
property DockRect: TRect;
__property TRect DockRect;
Use DockRect to determine the rectangle on which the control is docked if released.
C++ Examples:
/* The following example is taken from the docking demo. It shows how set permissions to dock dockable objects onto a docking site. */ void __fastcall TMainForm::LeftDockPanelDockDrop(TObject *Sender, TDragDockObject *Source, int X, int Y) { //OnDockDrop gets called AFTER the client has actually docked, //so we check for DockClientCount = 1 before making the dock panel visible. TPanel *panel = dynamic_cast<TPanel *>(Sender); if (panel->DockClientCount == 1) ShowDockPanel(panel, True, NULL); panel->DockManager->ResetBounds(True); //Make DockManager repaints it's clients. } void __fastcall TMainForm::LeftDockPanelDockOver(TObject *Sender, TDragDockObject *Source, int X, int Y, TDragState State, bool &Accept) { Accept = (dynamic_cast<TDockableForm*>(Source->Control) != NULL); if (Accept) { // Modify the DockRect to preview dock area. Types::TPoint TopLeft = LeftDockPanel->ClientToScreen(Point(0, 0)); Types::TPoint BottomRight = LeftDockPanel->ClientToScreen( Point(this->ClientWidth/3, LeftDockPanel->Height)); Source->DockRect = Types::TRect(TopLeft, BottomRight); } } void __fastcall TMainForm::LeftDockPanelUnDock(TObject *Sender, TControl *Client, TWinControl *NewTarget, bool &Allow) { //OnUnDock gets called BEFORE the client is undocked, in order to optionally //disallow the undock. DockClientCount is never 0 when called from this event. TPanel *panel = dynamic_cast<TPanel *>(Sender); if (panel->DockClientCount == 1) ShowDockPanel(panel, False, NULL); } void __fastcall TMainForm::LeftDockPanelGetSiteInfo(TObject *Sender, TControl *DockClient, TRect &InfluenceRect, TPoint &MousePos, bool &CanDock) { //if CanDock is true, the panel will not automatically draw the preview rect. CanDock = DockClient->ClassNameIs("TDockableForm"); if (!CanDock) { ShowMessage(L"GetSiteInfo CanDock went bad!"); } }
Delphi Examples:
{ The following example is taken from the docking demo. It shows how set permissions to dock dockable objects onto a docking site. } procedure TMainForm.LeftDockPanelDockDrop(Sender: TObject; Source: TDragDockObject; X, Y: Integer); begin //OnDockDrop gets called AFTER the client has actually docked, //so we check for DockClientCount = 1 before making the dock panel visible. if (Sender as TPanel).DockClientCount = 1 then ShowDockPanel(Sender as TPanel, True, nil); (Sender as TPanel).DockManager.ResetBounds(True); //Make DockManager repaints it's clients. end; procedure TMainForm.LeftDockPanelDockOver(Sender: TObject; Source: TDragDockObject; X, Y: Integer; State: TDragState; var Accept: Boolean); var ARect: TRect; begin Accept := Source.Control is TDockableForm; if Accept then begin //Modify the DockRect to preview dock area. ARect.TopLeft := LeftDockPanel.ClientToScreen(Point(0, 0)); ARect.BottomRight := LeftDockPanel.ClientToScreen( Point(Self.ClientWidth div 3, LeftDockPanel.Height)); Source.DockRect := ARect; end; end; procedure TMainForm.LeftDockPanelUnDock(Sender: TObject; Client: TControl; NewTarget: TWinControl; var Allow: Boolean); begin //OnUnDock gets called BEFORE the client is undocked, in order to optionally //disallow the undock. DockClientCount is never 0 when called from this event. if (Sender as TPanel).DockClientCount = 1 then ShowDockPanel(Sender as TPanel, False, nil); end; procedure TMainForm.LeftDockPanelGetSiteInfo(Sender: TObject; DockClient: TControl; var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean); begin //if CanDock is true, the panel will not automatically draw the preview rect. CanDock := DockClient is TDockableForm; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|