Go: Docking control in Expressbars uses

Source: Internet
Author: User

http://www.cnblogs.com/jxsoft/archive/2011/08/25/2152872.html1 Beginner 1.1 Introduction to Controls

Dock Panels

The dock panels is the most important part of building a docking application, and it is the Windows Local window inside the app that can place other VCL controls. When a dock panels is placed on a form, it automatically floats over the form. If you need to dock to a form, you need to use the Tdxdocksite control, and you can set the theme style.

Note that when you want to delete, copy, paste, or some other action on the dock panels control, you must use the control's context menu to implement it.

Dock panels can dock with each other, the result of docking has 2 types of-tab containers and side containers, for example, you can put side containers in a tab containers.

Dock Sites

Dock sites supports placing the dock panels, noting that the dock sites can only accept dock panels controls;

If there is no control on the dock sites, there will be a blank rectangular area placeholder, if you do not want to, you can use the following techniques:

L fill the entire form with a dock sites, then put a dock panels on it;

L if the AutoSize property of Docksites is set to True, its size will apply to the accepted dock panel or container;

Docking Manager

The Docking Manager control can centrally control all or part of a docked control. Note that it is not required, and if no docking manager,docking controller is placed on any form on application, the management of the docked control will take over. However, the docking controller only provides default settings and does not allow changes to the docking control's settings. In general, docking Manager is used.

1.2 How to customize the dock panels appearance

Expressdocking offers 4 pre-set display styles, Standard (similar to Delphi), Visual Studio. Net, Office, and Windows XP style. To specify the style at design time, you need to use the Viewstyle and Lookandfeel properties of the docking manager. Note the Lookandfeel property setting can only be used when the Viewstyle property is set to Vsuselookandfeel.

To specify a dock panel's caption, use the Caption property, set the icon to use the ImageIndex property, and, of course, provide docking manager with a ImageList.

1.3 Basic operations for docking

If you want to change the position of the dock panel, but do not want to embed it automatically over the dock site, hold down CTRL as you drag.

The Allowdockclients property of the docking control is the docking set position of the accepted control, and Allowdock sets the position for docking to another control. Set Allowfloating to False to prevent the docking control from floating and dockable set to False to not allow drag docking.

1.4 Create a visual Studio. NET-style interface

L Create a new application;

L Place a Tdxdocksite control on the form and set the Align property to alclient;

L Place a Tdxdockpanel control on the Tdxdocksite, Tdxdockpanel automatically fills the entire Tdxdocksite area. Set the Showcaption property to False to hide the panel title bar;

L Place a memo control on the Tdxdockpanel and set align to alclient;

L Set the Allowdockclients property of the dock panel, turn all the options to false, and block the docking of other dock panel;

Setting the Dttop option of the Allowdockclients property of the dock site to False will prevent the other dock panel from docking above it;

At this point, all the preparation steps are ready. You can now create new dock panel on the form, which can only be dragged and dropped to the edge of the form, in addition to the top. When a dock panel docks to the left side of the form, setting the AutoHide property will automatically add a side container control;

L The rest is going to cut into the theme, place a docking manager control, set the Viewstyle property to Vsnet, and the entire app's interface will turn into vs. NET style.

2 docking control at runtime 2.1 docking rules

The dock panel can only change size on the dock site. Expressdocking offers 2 types of stops: Dock sites, layout sites, and float sites. The dock sites is placed on the form to accept docking of the dock panel, and layout sites is automatically created on the dock site when there is a docking operation to provide a more flexible layout customization; float sites is the carrier of the floating dock panel;

Float sites is automatically created when the dock panel is floating, and the float site is destroyed once the dock panel docks.

Layout sites is also created automatically, which occurs after docking the dock panel. Layout site does not occupy space;

2.2 Controlling docking of dock panels at run time

The dock panel provides Dockto, Makefloating, and undock methods to perform docking operations.

The makefloating is floating when the dock panel leaves the dock site;

Undock is similar to makfloating, but hides the dock panel. This method is useful, for example, when a dock panel docks to another dock panel to form side container, you need to know if the target dock panel is in a tab container, if all previous dock The Panel has been undock, so you don't have to worry about it.

For example, dock the dock panel to the left:

Dxdockpanel1.dockto (dxDockSite1, dtleft, 0);

For example, one dock panel fills the bottom of the form, and the other dock panel places the right side of the non-filled area:

Dxdockpanel2.dockto (dxDockSite1, Dtbottom, 0); This step automatically creates a layoutdocksite to place the DxDockPanel2;

Dxdockpanel3.dockto (Dxdockpanel2.layoutdocksite, dtright, 0); Layout The new dock panel on DxDockPanel2 's layoutdocksite;

Docking Manager provides methods to store and load layouts, such as Savelayouttointfile, Savelayouttoregistry, Savelayouttostream, Loadlayoutfromintfile,loadlayoutfromregistry, Loadlayoutfromstream

2.3 Creating and Managing container control

The Dockto method that calls the docking control automatically creates a container, and when the undock occurs, the container space is automatically destroyed;

The Makefloating method that calls the docking control automatically destroys the container control;

L Call the container's activechildindex to find the current active dock panel;

The Dock panel has a dockindex attribute that determines its index in the container;

L containers have children,childcount, Validchildren, and Validchildcount properties that can be used to access the container's members in the dock panel;

The Parentdockcontrol, Tabcontainer, and Sidecontainer properties of the dock panel can be used to access the parent docking control;

For example, the following code demonstrates:

Delphi

Var

Atabcontainer:tdxtabcontainerdocksite;

Asidecontainer:tdxsidecontainerdocksite;

Begin

Create a side container by docking the second panel

To the center of the first one

Dxdockpanel2.dockto (DxDockPanel1, dtclient, 1);



Obtaining the TAB container created

Atabcontainer: = Dxdockpanel1.tabcontainer;

If Atabcontainer = nil then Exit;

Adding the third panel to the tab container

Dxdockpanel3.dockto (Atabcontainer, dtclient, 2);

Switching to the first Panel (tab)

Atabcontainer.activechildindex: = Dxdockpanel1.dockindex;

Create a vertical side container

Dxdockpanel4.dockto (DxDockPanel5, dttop, 0);



Obtain the side container created

Asidecontainer: = Dxdockpanel4.sidecontainer;

If Asidecontainer = nil then Exit;

Expand the top panel within the side container

Asidecontainer.activechildindex: = Dxdockpanel4.dockindex;

Dock the side container to a site ' s right edge

Asidecontainer.dockto (dxDockSite1, dtright, 0);

Dock the tab container to a site ' s bottom edge

Atabcontainer.dockto (dxDockSite1, Dtbottom, 0);



End

2.4 Dynamically creating docked controls at run time

The docking control relies on the Visible property to set whether it is displayed. The control is also hidden when the control's Close method is called, but remember that the docking manager's dofreeonclose option is disabled, otherwise the Close method destroys the control, and another way to hide the control is to use undock. Calling free is also destroying the control.

L do not have to create container controls manually, as they are automatically created and destroyed with docking operations;

If a control is hidden, the container also retains its position, and when displayed again, it will appear in the same position;

L IF the auto-hide feature is turned on, then setting the Visible property to false will not work, so it is best to suppress the auto-hide feature before hiding such controls;

Docking controls provide some events to respond to these actions: VisibleChanged, visiblechaning, OnClose, onclosequery;

• Example of displaying and hiding docking controls

  Procedure TForm1. Button1Click (Sender:tobject);

Begin

If Dxdockpanel1.autohide and not dxdockpanel1.visible then

Begin

Dxdockingcontroller.beginupdate;

Try

Make the panel's client area visible in screen

Dxdockpanel1.visible: = True;

Hide the Panel

Dxdockpanel1.visible: = False;

Finally

Dxdockingcontroller.endupdate;

End

End

Else

Dxdockpanel1.visible: = Not dxdockpanel1.visible;

End

  

L Create docked controls dynamically

Procedure Tform1.formcreate (Sender:tobject);

Begin

Specify the Open dialog World抯 filter

Opendialog1.filter: = ' *.bmp|*.bmp ';

With DxDockingManager1 do

Begin

Force dock controls to being destroyed when closed

Options: = Dxdockingmanager1.options + [dofreeonclose];

Specify the default tabs position and

The dock controls Paint style

Defaulttabcontainersiteproperties.tabsposition: = Tctptop;



Viewstyle: = vsnet;

End

End



Procedure Tform1.formkeydown (Sender:tobject; var Key:word;

Shift:tshiftstate);

Var

Apicture:tpicture;

Apanel:tdxdockpanel;

Aimage:timage;

Alastindex, I:integer;

Begin

If Key = Vk_insert Then

Begin

Open the file and create the corresponding image object



If not Opendialog1.execute () then Exit;

Apicture: = Tpicture.create ();

Apicture.loadfromfile (Opendialog1.filename);

Create a new panel that'll hold the image

Apanel: = Tdxdockpanel.create (self);

Apanel.caption: = Extractfilename (Opendialog1.filename);

Check whether the dock site already has docked controls

If Dxdocksite1.childcount > 0 Then

Begin

Add the Panel to the tab container



Alastindex: = dxdocksite1.children[1]. ChildCount;

Apanel.dockto (Dxdocksite1.children[1], dtclient, Alastindex + 1);

End

Else

Dock the panel to the dock site

Apanel.dockto (dxDockSite1, dtclient, 0);

Create an image control and place it on the panel

Aimage: = Timage.create (self);

Aimage.parent: = Apanel;

Aimage.align: = alclient;

Aimage.center: = True;

Aimage.picture: = apicture;



End

Delete all panels if the DELETE key has been pressed

If Key = Vk_delete Then

Begin

For I: = 0 to Dxdockingcontroller.dockcontrolcount-1 do

Begin

If Dxdockingcontroller.dockcontrols[i] is Tdxdockpanel then

Dxdockingcontroller.dockcontrols[i]. Close;

End

End

End

  

Go: Docking control in Expressbars uses

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.