转:ExpressBars中的停靠控件使用
http://www.cnblogs.com/jxsoft/archive/2011/08/25/2152872.html
1 新手上路
1.1 控件简介
Dock panels
Dock panels是建立停靠应用的最主要部分,是在应用内部的windows局部窗口,可以放置其他的VCL控件。当一个Dock panels放在Form上后,它会自动漂浮在Form之上。如果需要停靠到窗体中,需要使用TdxDockSite控件,并且可以设置主题风格。
注意,当要对Dock panels控件进行删除、复制粘贴或者其他一些操作时,务必使用控件的上下文菜单来实现。
Dock panels之间可以互相停靠,停靠的结果有2种类型-tab containers 和side containers,例如,可以将side containers放到一个tab containers中。
Dock Sites
Dock Sites支持放置Dock panels,注意Dock Sites只能接受Dock panels控件;
如果没有Dock Sites上没有控件时,会有一个空白的矩形区域占位,如果不想这样,可以采用以下技巧:
l 用一个Dock Sites填充整个Form,然后在上面放上一个Dock panels;
l 如果将DockSites的autoSize属性设为true,它的大小会自适用所接受的Dock Panel或者container;
Docking Manager
Docking Manager控件可以集中控制所有或者部分的停靠控件。注意,它不是必须的,如果在Application的任何窗体上都没有放置Docking Manager,docking controller会接管停靠控件的管理。但是docking controller只提供默认设置,不允许改变停靠控件的设置。一般情况下都会使用Docking Manager。
1.2 如何定制Dock Panels外观
ExpressDocking提供4种预先设置好显示风格,标准(类似于Delphi)、Visual Studio .Net、office和Windows Xp风格。为了在设计时就能指定风格,需要使用Docking Manager的ViewStyle和LookAndFeel属性。注意LookAndFeel属性设置只能在ViewStyle属性设置为vsUseLookAndFeel时使用。
要指定一个dock panel的caption,使用Caption属性,设置图标使用ImageIndex属性,当然之前要给docking manager提供一个imageList。
1.3 停靠的基本操作
如果要改变dock panel的位置,但是不想在经过dock site上方的时候自动嵌入,可以在拖动的时候按住CTRL。
停靠控件的AllowDockClients属性为接受的控件停靠设定位置,AllowDock为停靠到其他控件设定位置。设置AllowFloating为False,可以禁止停靠控件漂浮,Dockable设置为False,则不允许拖动停靠。
1.4 创建一个Visual Studio .Net风格的界面
l 新建一个应用;
l 在窗体上放置一个TdxDockSite控件,并设置Align属性为alClient;
l 在TdxDockSite上放置一个TdxDockPanel控件,TdxDockPanel会自动充满整个TdxDockSite的区域。设置ShowCaption属性为False,隐藏面板标题栏;
l 在TdxDockPanel上放置一个memo控件,并设置Align为alClient;
l 设置dock panel的AllowDockClients属性,将所有的选项为False,阻止其他dock panel的停靠;
l 将dock site的AllowDockClients属性的dtTop选项设为False,将会阻止其他dock panel停靠到其上方;
l 至此,所有准备步骤已经就绪。现在可以在窗体上新建一些dock panel,这些dock panel只能被拖放到窗体的边缘,除了上方。当一个dock panel停靠到窗体的左边,设置AutoHide属性,将会自动加入一个side container控件;
l 剩下的事情就要切入主题了,放置一个docking manager控件,设置ViewStyle属性为vsNET,整个应用的界面就会变成VS .NET风格了。
2 运行时的停靠控件
2.1 停靠规则
Dock panel 只能在dock site上该能改变大小。ExpressDocking提供2种停靠点类型:dock sites、layout sites和float sites。Dock sites 是放置在窗体上,用来接受dock panel的停靠;Layout sites是当有停靠操作时,自动创建在dock site上,以提供更灵活的布局定制;Float sites是漂浮dock panel的载体;
当dock panel处于漂浮状态,会自动创建Float sites,一旦dock panel停靠,Float site就会被销毁;
Layout sites 也是自动创建的,在dock panel停靠后发生。Layout site不会占据空间;
2.2 在运行时控制dock panels的停靠
Dock panel 提供DockTo, MakeFloating和UnDock方法来执行停靠操作。
MakeFloating是使dock panel离开Dock site而处于漂浮状态;
UnDock类似于MakFloating,但是会隐藏Dock panel。这个方法很有用处,例如当一个dock panel停靠到另外一个dock panel形成side container,你需要知道目标dock panel是不是在一个tab container中,如果之前所有的dock panel都被UnDock了,那么你就不必担心担心了。
例如将dock panel停靠到左边:
dxDockPanel1.DockTo(dxDockSite1, dtLeft, 0);
例如将一个dock panel充满窗体的下方,另外一个dock panel放置未充满区域的右侧:
dxDockPanel2.DockTo(dxDockSite1, dtBottom, 0); //此步会自动创建一个LayoutDockSite来放置dxDockPanel2;
dxDockPanel3.DockTo(dxDockPanel2.LayoutDockSite, dtRight, 0); //在dxDockPanel2的LayoutDockSite上来布局新dock panel;
docking manager提供一些方法来存储和加载布局,这些方法是SaveLayoutToIntFile, SaveLayoutToRegistry, SaveLayoutToStream, LoadLayoutFromIntFile,LoadLayoutFromRegistry, LoadLayoutFromStream
2.3 创建和管理Container Control
l 调用停靠控件的DockTo方法就会自动一个创建容器;当UnDock发生后,会自动销毁容器空间;
l 调用停靠控件的MakeFloating方法会自动销毁容器控件;
l 调用容器的ActiveChildIndex来查找当前活动dock panel;
l Dock Panel有个DockIndex属性,决定了其在容器中的索引;
l 容器有Children,ChildCount, ValidChildren和ValidChildCount属性,可以用来访问容器的成员dock panel;
l Dock panel的ParentDockControl, TabContainer和SideContainer属性可以用来访问父停靠控件;
例如下面的代码演示:
- // 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 在运行时动态创建停靠控件
停靠控件依靠Visible属性来设置是否显示。当调用控件的Close方法也会隐藏控件,但要记住,需要将docking manager的doFreeOnClose选项禁用,否则,Close方法会销毁控件;另外一个隐藏控件的方法是使用UnDock。调用Free也是销毁控件。
l 不必手工创建容器控件,因为他们是伴随停靠操作自动创建和销毁的;
l 如果一个控件隐藏,容器还会为它保留位置,当再次显示时,还会出现在同样的位置;
l 如果开启自动隐藏特性,再设置Visible属性为False会无效;因此在隐藏这类控件前,最好先取消自动隐藏特性;
停靠控件提供一些事件来响应这些操作:VisibleChanged, VisibleChaning, OnClose, OnCloseQuery;
l 显示和隐藏停靠控件的示例
- 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 on screen
- dxDockPanel1.Visible := True;
- // hide the panel
- dxDockPanel1.Visible := False;
- finally
- dxDockingController.EndUpdate;
- end;
- end
- else
- dxDockPanel1.Visible := not dxDockPanel1.Visible;
- end;
l 动态创建停靠控件
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- // specify the open dialog抯 filter
- OpenDialog1.Filter := '*.bmp|*.bmp';
- with dxDockingManager1 do
- begin
- // force dock controls to be 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 will 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;
转:ExpressBars中的停靠控件使用的更多相关文章
- 在C#中使用Panel控件实现在一个窗体中嵌套另一个窗体
在C#中使用Panel控件实现在一个窗体中嵌套另一个窗体 在C#中使用Panel控件实现在一个窗体中嵌套另一个窗体ShowAllPage sAllPage = new ShowAllPage(); ...
- PyQt5复杂控件(树控件、选项卡控件(滚动条控件、多文档控件、停靠控件)
1.树控件的基本使用方法QTreeWidget'''QTreeWidget树控件的使用方法添加图标,添加表格,添加复选框等'''from PyQt5.QtWidgets import *from Py ...
- 在DevExpress程序中使用SplashScreenManager控件实现启动闪屏和等待信息窗口
在我很早的WInform随笔<WinForm界面开发之"SplashScreen控件">有介绍如何使用闪屏的处理操作,不过那种是普通WInform和DevExpress ...
- 在WPF中使用WinForm控件方法
1. 首先添加对如下两个dll文件的引用:WindowsFormsIntegration.dll,System.Windows.Forms.dll. 2. 在要使用WinForm控 ...
- wpf telerik中的book控件
下载 telerik中的书本控件,仅供学习使用.
- [原创]在Framelayout中放置button控件出现的覆盖问题
android Framelayout(帧布局)是很常用的布局,主要用来处理需要多个view叠加显示的情况. 然而在使用中,我发现Framelayout中的Button控件,会挡住所有其他控件,而不论 ...
- (转)客户端触发Asp.net中服务端控件事件
第一章. Asp.net中服务端控件事件是如何触发的 Asp.net 中在客户端触发服务端事件分为两种情况: 一. WebControls中的Button 和HtmlControls中的Type为su ...
- 在web中使用windows控件,实现摄像头功能
最近做的一个Web版的视频会议项目,需要在网页中播放来自远程摄像头采集的实时视频,我们已经有了播放远程实时视频的使用C#编写的windows控件,如何将其嵌入到网页中去了?这需要使用一种古老的技术,A ...
- WPF中的image控件的Source赋值
WPF中的Image控件Source的设置 1.XAML中 简单的方式(Source="haha.png"); image控件的Source设置为相对路径后(Source=&quo ...
随机推荐
- SlimDX.dll安装之后所在位置
C:\Windows\Microsoft.NET\assembly\GAC_64\SlimDX\v4.0_4.0.13.43__b1b0c32fd1ffe4f9\SlimDX.dll
- osgearth使用prjected投影
In projected mode, you have to specify a map profile (i.e. a map projection). You also need to tell ...
- RedHat下安装MySQL
下载mysql 解压tar -xvf mysql-5.7.16-1.el6.x86_64.rpm-bundle.tar 安装MySQL-server包 rpm -ivh mysql-community ...
- iOS高效调试
写代码难免出现bug. 储备些调试技能绝对能够提高你的工作效率,让bug无所遁形.下面就和大家分享一些我在工作中常用的iOS调试小技能. 1. 打印 最简单,基础的调试方法就是打印日志了.贴出两段封装 ...
- Eclipse 安装SVN
地址:http://wenku.baidu.com/link?url=ntQy2-1CjlNyUpO0-4uhROrc9jCo12Yifh7MkPULmY_dCybl6SEH99SxYxEbZQEiW ...
- JS判断IE版本并在页面显示内容
<script type="text/javascript"> var isIE = function (ver) { var b = document.createE ...
- 关于内存管理/set/get方法
MRC状态下 1 任何继承NSObject的对象,存放于堆控件中,都需要手动管理内存 .2 基本数据类型放到栈中,对象放到堆空间中,内存是有系统管理的.(int\float\enum\struct) ...
- hdu1722(gcd)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1722 题意:要使一块蛋糕既能均分给a个人,又能均分给b个人,问至少需要分成几块(不需要每块都一样大小) ...
- iOS - OC/Swift:验证手机号/固话用正则表达式
/** * 验证手机号是否正确 * @param unknown_type $mobile */ OC: - (BOOL)isMobileNumber:(NSString *)mobileNum { ...
- Android -- getQuantityString无效
原文:http://www.xuebuyuan.com/1510993.html 原因:中文没有复数语法.