使用ObjectARX2015开发类似outlook浮动面板窗格
ObjectARX开发环境下的AutoCAD对话框设计

袁梅李亚萍张竟
(武汉大学城市建设学院,湖北 武汉 430072)
摘要:在ObjectARX开发环境下,AutoCAD支持两种格式的对话框:PDB对话框和Windows机制的对话框。从简单实例出发,本文介绍了这两种格式的对话框设计。
关键词:ObjectARX;AutoCAD;PDB;MFC;对话框
}
以上只给出了主调用函数drive_main()和回调函数print_cb()、ok_cb()的部分代码,相当于ObjectARX应用程序中的用户程序主体函数部分,Mypdb.cpp中头文件部分、函数声明部分和接口函数部分和一般的ObjectARX应用程序要求相同,不再写出。必须注意,头文件中一定要有#include“adsdlg.h”。
Microsoft基础类库(MFC)给软件开发者提供了一种便捷快速建立标准的用户界面的方法。ObjectARX开发环境也提供了一系列基于MFC的用户界面类,我们可以使用这些类设计Windows风格的对话框。使用Windows对话框的ObjectARX应用程序将使自己的界面与AutoCAD内建对话框界面完全一致,且可与其它Windows应用程序紧密集成在一起,共享Windows的各种资源,而且程序的维护也非常方便。在ObjectARX应用程序中使用MFC最明显的优点是可以充分利用MSVC(Microsoft Visual C++)开发环境提供的先进技术和工具,实现程序界面的可视化设计。Windows对话框也是Autodesk极力推荐开发者使用的对话框。
在CAD软件开发中,对话框的设计是软件开发者非常关心的问题之一。AutoCAD除了使用命令行与用户进行交互外,还可使用对话框。对话框是一种边界固定的窗口,也是一种最先进、最流行的人机交互界面。运用对话框可以方便地实现程序设计时的数据传输和信息传输,,所以在当今的几乎所有的软件都要用到对话框界面与用户交流。在CAD的二次开发中,可以采用两种方式使用对话框技术:,一种是PDB格式,即使用AutoCAD系统本身提供的可编程对话框技术,另一种是使用Windows机制的对话框设计技术。
ObjectARX开发教程(转)——第1课:概述

ObjectARX开发教程(转)——第1课:概述第1课:概述介绍ObjectARX是AutoCAD运⾏时扩展。
使⽤ObjectARX SDK(软件开发⼯具包),您可以构建应⽤程序,以⽀持AutoCAD功能的开发,例如命令,对话框,实体,对象等。
ObjectARX应⽤程序本质上是⼀个动态链接的DLL库,可以将其加载到AutoCAD⼯作环境中,并允许您如上所述访问属性。
为了能够构建DLL库,在安装Microsoft Visual Studio .NET环境时需要遵循⼀些强制性规则,并确保该应⽤程序已被AutoCAD批准。
此应⽤程序的实现与本机功能相同。
这样,Autodesk⽤户可以使⽤ObjectARX直接构建您已经知道的产品,例如Autodesk MAP和Architectural Desktop等。
⽤户要求由于ObjectARX不是根据⽤户要求的简单⼯具,因此需要⼤量的精⼒和某些技能。
如果您不这样做,我建议您先学习更多的技能,然后再返回以继续该课程。
学习ObjectARX的最低要求基本上是:Visual Studio .NET基础;有点C ++知识;AutoCAD的⾼级知识;MFC概念(Microsoft基础类);⾯向对象技术(Objective-iented Techniques);话虽如此,本课程不是复杂的教程,也不是针对⾼级功能的。
我相信在学习了ObjectARX的基础知识和关键概念之后,您可以⾃⼰进⼀步发展。
我不会关注.NET使本课程尽可能简单的功能。
⼀旦您从内部学习并了解了AutoCAD的⼯作原理,您将了解ObjectARX的功能并能够构建出⾊的应⽤程序!如何使⽤ObjectARX SDK下载ObjectARX SDK并将其解压缩到硬盘后,您将在其中找到以下⽬录:\ arxlabs:⽬录包含代表ObjectARX不同⽅⾯的库(实验室)。
\ classmap:包含AutoCAD图形以及ObjectARX对象层次树的⽬录。
如何创建一个ObjectArx程序

如何创建一个ObjectArx程序?本小节通过一个简单的实例来讲述ARX程序的创建过程,介绍编制Object ARX程序的一些基本步骤和原则,并初步了解ARX程序与AutoCAD进行通讯的方式。
如同学习其它计算机语言一样,我们首先来创建一个最简单的ARX程序—“Hello.ARX”,在AutoCAD 2002中加载并运行该程序,将会在命令行出现-“Hello, ObjectARX!”。
38.2.1 建立ARX程序的基本步骤由于ARX程序是一种可以共享AutoCAD地址空间并对AutoCAD进行直接调用的动态链接库,因此应该按照下列基本步骤建立ARX程序:(1) 创建自定义类来实现新的命令:用户可以从ARX类层次关系中的大多数类和符号表类中派生自己的类。
(2) 决定ARX程序应该响应的AutoCAD消息:AutoCAD通过向ARX程序发出一系列的消息指明在它内部发生的特殊事件,ARX程序必须对其中的某些消息作出反映,并触发相应的操作。
(3) 实现应用程序与AutoCAD通信的入口:AutoCAD通过函数acrxEntryPoint()来调用ARX程序,而不是象普通的C++程序那样使用main()函数。
函数acrxEntryPoint()中可以用switch语句处理AutoCAD的各种返回信息,根据不同信息执行不同的函数,并返回状态码。
如果针对特定的消息返回出错代码,则必须用case语句来处理。
最后,必须用AcRx::kRetOk 作为函数acrxEntryPoint()的最终返回值。
(4) 完成ARX程序的初始化:用户必须在acrxEntryPoint()函数的AcRx::kInitAppMsg 事件中或者该事件调用的函数(例如:initApp()函数)中,对程序中自定义的所有类进行初始化,然后调用acedRegCmds->addCommand()函数在AutoCAD命令堆栈中注册新命令。
(5) 实现卸载(Unload)功能:用户必须在acrxEntryPoint()函数的AcRx:: kUnloadAppMsg 事件中或者该事件调用的函数(例如:unloadApp()函数)中,调用acedRegCmds->removeGroup()函数将initApp()函数中注册的新命令组从AutoCAD命令堆栈中清除,调用deleteAcRxClass()函数清除程序中自定义的任何类,然后删除所有由应用程序添加到AutoCAD中的对象,并清除所有与AcDbObject、AcDbDatabase、AcRxDynamicLinker或AcEditor对象相关联的事件反应器。
objectarx 开发人员手册

ObjectARX开发人员手册目录一、ObjectARX开发简介1.1 什么是ObjectARX?1.2 ObjectARX的应用领域1.3 ObjectARX的基本原理1.4 ObjectARX的发展历程二、ObjectARX环境搭建2.1 开发环境准备2.2 ObjectARX SDK安装2.3 开发工具选择2.4 环境配置及注意事项三、ObjectARX开发入门3.1 基本概念及术语3.2 ObjectARX编程框架3.3 第一个ObjectARX程序四、ObjectARX开发核心知识4.1 对象模型4.2 数据访问和修改4.3 事件处理4.4 自定义命令和操作4.5 交互式绘图五、ObjectARX开发高级技巧5.1 高效数据管理5.2 多线程编程5.3 性能优化5.4 构建扩展应用程序六、ObjectARX开发实例6.1 绘图应用实例6.2 数据处理应用实例6.3 CAD环境集成实例6.4 其他领域实例七、ObjectARX开发注意事项7.1 内存管理7.2 线程安全7.3 安全性考虑7.4 与AutoCAD版本兼容性7.5 其他注意事项八、ObjectARX开发资源8.1 冠方文档和教程8.2 开发社区和论坛8.3 第三方扩展库8.4 实用工具和示例九、ObjectARX开发未来展望9.1 行业发展趋势9.2 技术更新和发展9.3 ObjectARX的发展方向一、ObjectARX开发简介1.1 什么是ObjectARX?ObjectARX是AutoCAD的二次开发接口,简单来说,它是AutoCAD的扩展开发评台。
通过ObjectARX,开发者可以利用C++、C#、VB等语言编写自定义应用程序,扩展和定制AutoCAD的功能,实现各种与CAD相关的应用开发。
1.2 ObjectARX的应用领域ObjectARX广泛应用于工程设计、土木工程、建筑设计、机械设计等领域。
开发者可以利用ObjectARX开发CAD扩展功能、自定义命令、数据处理工具、智能绘图等应用,帮助用户提高工作效率,满足特定行业的需求。
ObjectARX学习笔记007:创建模态对话框的一般步骤

ObjectARX学习笔记007:创建模态对话框的⼀般步骤
1.新建⼀个⼯程,注意将"使⽤MFC"选项勾上。
2.使⽤【insert/Resouce】菜单项插⼊⼀个对话框。
3.此时会弹出⼀个窗体,直接按Enter键可以调出【属性】⾯板。
设置窗体的ID和窗体的Caption。
4.可以点击【属性】⾯板左上⾓的图钉图标将其常显。
5.向窗体中插⼊控件,依次设置其ID与Caption。
6.按Ctrl+W为对话框资源创建⼀个类。
此时系统会在⼯程中添加⼀个.cpp⽂件和⼀个对应的.h⽂件。
7.注册⼀个新命令,⽤于显⽰新的对话框。
8.在xxxCommands.cpp⽂件中应引⽤6中对应类的.h头⽂件。
9.在6中对应类的.h头⽂件中应引⽤资源⽂件头resouce.h,否则程序将找不到对话框资源中控件的定义。
类似于Outlook的导航菜单(JS)

类似于Outlook的导航菜单(JS)正文:看到一个类似于Outlook的导般菜单,功能挺不错的,而且制作方法也较简单,特简单介绍一下,先请参看效果!点击这里预览效果页面制作方法:1、在<body>插入代码:<SCRIPT>function showitem(id,name){return ("<span><a href='"+id+"' target=_self>"+name+"</a></span><br>")}function switchoutlookBar(number){var i = outlookbar.opentitle;outlookbar.opentitle=number;var id1,id2,id1b,id2bif (number!=i && outlooksmoothstat==0){if (number!=-1){if (i==-1){id2="blankdiv";id2b="blankdiv";}else{id2="outlookdiv"+i;id2b="outlookdivin"+i;document.all("outlooktitle"+i).style.border="1px none navy";document.all("outlooktitle"+i).style.background="#006CD9";document.all("outlooktitle"+i).style.color="#ffffff";document.all("outlooktitle"+i).style.textalign="center";}id1="outlookdiv"+numberid1b="outlookdivin"+numberdocument.all("outlooktitle"+number).style.border="1px none white";document.all("outlooktitle"+number).style.background="#0 06CD9"; //titledocument.all("outlooktitle"+number).style.color="#ffffff";document.all("outlooktitle"+number).style.textalign="center ";smoothout(id1,id2,id1b,id2b,0);}else{document.all("blankdiv").style.display="";document.all("blankdiv").sryle.height="100%";document.all("outlookdiv"+i).style.display="none";document.all("outlookdiv"+i).style.height="0%";document.all("outlooktitle"+i).style.border="1px none navy";document.all("outlooktitle"+i).style.background="#006CD9";document.all("outlooktitle"+i).style.color="#ffffff";document.all("outlooktitle"+i).style.textalign="center";}}}function smoothout(id1,id2,id1b,id2b,stat){if(stat==0){tempinnertext1=document.all(id1b).innerHTML;tempinnertext2=document.all(id2b).innerHTML;document.all(id1b).innerHTML="";document.all(id2b).innerHTML="";outlooksmoothstat=1;document.all(id1b).style.overflow="hidden";document.all(id2b).style.overflow="hidden";document.all(id1).style.height="0%";document.all(id1).style.display="";setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id 2b+"',"+outlookbar.inc+")",outlookbar.timedalay);}else{stat+=outlookbar.inc;if (stat>100)stat=100;document.all(id1).style.height=stat+"%";document.all(id2).style.height=(100-stat)+"%";if (stat<100)setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id 2b+"',"+stat+")",outlookbar.timedalay);else{document.all(id1b).innerHTML=tempinnertext1;document.all(id2b).innerHTML=tempinnertext2;outlooksmoothstat=0;document.all(id1b).style.overflow="auto";document.all(id2).style.display="none";}}}function getOutLine(){outline="<table "+outlookbar.otherclass+">";for (i=0;i<(outlookbar.titlelist.length);i++){outline+="<tr><td name=outlooktitle"+i+" id=outlooktitle"+i+" ";if (i!=outlookbar.opentitle)outline+=" nowrap align=center style='cursor:hand;background-color:#006CD9;color:#ffffff;height:5;border:1 none navy' ";elseoutline+=" nowrap align=center style='cursor:hand;background-color:#006CD9;color:white;height:5;border:1 none white' ";outline+=outlookbar.titlelist[i].otherclassoutline+=" onclick='switchoutlookBar("+i+")'>";outline+=outlookbar.titlelist[i].title+"</td></tr>";outline+="<tr><td name=outlookdiv"+i+" valign=top align=center id=outlookdiv"+i+" style='width:100%"if (i!=outlookbar.opentitle)outline+=";display:none;height:0%;";elseoutline+=";display:;height:100%;";outline+="'><div name=outlookdivin"+i+" id=outlookdivin"+i+"style='overflow:auto;width:100%;height:100%'>";for (j=0;j<outlookbar.itemlist[i].length;j++)outline+=showitem(outlookbar.itemlist[i][j].key,outlookbar.i temlist[i][j].title);outline+="</div></td></tr>"}outline+="</table>"return outline}function show(){var outline;outline="<div id=outLookBarDiv name=outLookBarDiv style='width=100%;height:100%'>"outline+=outlookbar.getOutLine();outline+="</div>"document.write(outline);}function theitem(intitle,instate,inkey){this.state=instate;this.otherclass=" nowrap ";this.key=inkey;this.title=intitle;}function addtitle(intitle){outlookbar.itemlist[outlookbar.titlelist.length]=new Array();outlookbar.titlelist[outlookbar.titlelist.length]=new theitem(intitle,1,0);return(outlookbar.titlelist.length-1);}function additem(intitle,parentid,inkey){if (parentid>=0 && parentid<=outlookbar.titlelist.length){outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].le ngth]=new theitem(intitle,2,inkey);outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].le ngth-1].otherclass=" nowrap align=left style='height:5' ";return(outlookbar.itemlist[parentid].length-1);}elseadditem=-1;}function outlook(){this.titlelist=new Array();this.itemlist=new Array();this.divstyle="style='height:100%;width:100%;overflow:auto' align=center";this.otherclass="border=0 cellspacing='0' cellpadding='0' style='height:100%;width:100%'valign=middle align=center ";this.addtitle=addtitle;this.additem=additem;this.starttitle=-1;this.show=show;this.getOutLine=getOutLine;this.opentitle=this.starttitle;this.reflesh=outreflesh;this.timedelay=50;this.inc=10;}function outreflesh(){document.all("outLookBarDiv").innerHTML=outlookbar.get OutLine();}function locatefold(foldname){for (var i=0;i<outlookbar.titlelist.length;i++)if(foldname==outlookbar.titlelist[i].title){outlookbar.starttitle=i;outlookbar.opentitle=i;}}var outlookbar=new outlook();var tempinnertext1,tempinnertext2,outlooksmoothstatoutlooksmoothstat = 0;</SCRIPT>2、下载list_nav.js文件,打开list_nav.js文件,修改相应的文字与URL地址。
[转]objectarx加载菜单-ObjectARX中右键(快捷)菜单的实现方法
[转]objectarx加载菜单-ObjectARX中右键(快捷)菜单的实现⽅法 右键菜单,也叫快捷菜单,在Windows编程中叫上下⽂(context)菜单。
ObjectARX本⾝提供了⼀套处理上下⽂菜单的机制。
在ObjectARX类库中有⼀个名为AcEdUIContext的类,此类负责在ObjectARX应⽤中的上下⽂菜单中添加⾃⼰的菜单项,⽽原菜单项不会被破坏,这也是此种⽅法的优点之⼀。
⽤AcEdUIContext类添加菜单时,菜单项的数⽬没有限制,但必须是⽂本菜单。
菜单可以层叠,但不允许使⽤键盘加速键,不能够在状态⾏显⽰快捷菜单命令状态提⽰。
此类可以处理三种情况下的上下⽂菜单:⼀个默认上下⽂菜单,⼆是实体对象上下⽂菜单,三是命令执⾏时上下⽂菜单。
虽然菜单出现的时机不同,但⽅法基本相同,它们之间主要的不同是所⽤的加载和卸载函数不同。
下⾯加以详细介绍。
在AcEdUIContext为中包含了三个重要的成员函数,他们分别是:(1) AutoCAD系统获取快捷菜单句柄函数virtual void * getMenuContext(const AcRxClass * unnamed,const AcDbObjectIdArray& unnamed) = 0;其中,第⼀个参数unnamed 是当前所选择的实体的对象句柄,第⼆个参数unnamed是所选实体的实体ID数组。
这两个参数只有在实体对象上下⽂菜单中有效。
(2) 菜单项命令事件响应函数virtual void onCommand(Adesk::UInt32 unnamed) = 0;其中,unnamed是相应菜单项的菜单ID。
此函数在⽤户选择执⾏快捷菜单中的某个菜单项时被调⽤。
(3) 菜单更新函数virtual void OnUpdateMenu();AutoCAD在快捷菜单弹出之前调⽤此函数。
相当于MFC中的菜单更新事件,我们可以在这个函数中改变菜单项的检查状态或使能菜单项等。
vs2015 wpf案例
vs2015 wpf案例在Visual Studio 2015中创建一个简单的WPF(Windows Presentation Foundation)应用程序的案例如下:步骤1:打开Visual Studio 2015,选择“创建新项目”。
步骤2:在“创建新项目”对话框中,选择“WPF App (.NET Framework)”,然后在“名称”和“位置”中输入相应的信息,最后点击“创建”。
步骤3:在“解决方案资源管理器”中,右键点击“”,选择“编辑器”->“XAML”,打开文件。
步骤4:在文件中,你可以添加一些控件,例如一个按钮(Button)和一个标签(Label)。
以下是一个简单的示例:```xml<Window x:Class=""xmlns="xmlns:x="Title="MainWindow" Height="350" Width="525"><Grid><Button Content="Click me" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="30"/><Label Content="Hello, World!" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="100" Height="30"/></Grid></Window>```步骤5:在文件中,你可以添加按钮的点击事件处理程序。
MFCOutlookBar功能的使用
MFCOutlookBar功能的使用CMFCOutlookBar类该功能实现的是类似Outlook 2000或者Outlook2003的导航窗格的外观模式。
CMFCOutlookBar对象包含一个CMFCOutlookBarT abContrl类和一系列的Tabs 表。
Tab表即可为CMFCOutlookBarPane类的对象,也可以为CWnd继承类的对象。
对于用户来说,Outlook bar是由一系列控件和一个显示区域。
class CMFCOutlookBar : public CBaseTabbedPane要实现CMFCOutlookBar控件,可以按以下步骤实现:1、在main frame window类中定义一个CMFCOutlookBar对象。
如:class CMainFrame:public CMDIFrameWnd{…CMFCOutlookBar m_wndOutlookBar;CMFCOutlookBarPane m_ wndOutlookBarPane;…};2、在main frame处理WM_CREATE消息时。
调用CMFCOutlookBar::Create方法来创建Outlook bar tab控件。
如:m_wndOutlookBar.Create (_T("Shortcuts"), this, CRect (0, 0, 100, 100),ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT);3、通过调用CBaseTabbedPane::GetUnderlyingWindow函数获得CMFCOutlookBarT abCtrl对象的指针。
CMFCOutlookBarT abCtrl*pOutlookBar=(CMFCOutlookBarTabCtrl*)m_wndOu tlookBar.GetUnderlyingWindow ();4、为每一个包含button的tab创建一个CMFCOutlookBarPane 类的对象。
第二章ObjectARX类库简介
第⼆章ObjectARX类库简介ObjectARX环境包含下列⼏组类和函数:AcRx ⽤于绑定应⽤程序及运⾏时类的注册和标识的类。
AutoCAD Registration Extension;AcEd 注册本地AutoCAD命令和AutoACD事件通知的类。
AutoCAD Envent Directory;AcDb AutoCAD数据库类。
AutoCAD DataBase ;AcGi 显⽰AutoACD实体的图形类。
AutoCAD Graph Interface;AcGe 公⽤线性数学和⼏何学对象应⽤类。
AutoCAD Geometry Entity;AcRx库提供了⼀些系统级类,⽤于DLL的初始化和链接及运⾏时类的注册和标识。
该库的基类是AcRxObject,它提供如下功能:对象运⾏时类标识和继承分析、运⾏时向既有类添加新协议、对象⽐较测试、对象复制。
运⾏时类型标识是AcRxObject的每个⼦类都有⼀个相关的类描述者对象(AcRxClass类型),⽤于运⾏时类型的标识。
最常⽤函数:AcRxObject::isA(); ⽤于类识别,被识别的类必须能够测试其类型。
AcRxObject::isKindOf(); 也是⽤于类识别,但这⾥的类能够被测试其类型,或者测试其派⽣类的类型。
AcRxObject::desc(); 返回类名。
AcRxObject::cast(); 试图将⼀个基类转换成更⾼级的类。
如果转换成功,基类对象的指针将是转换后类型的指针。
该库也可以对应⽤程序进⾏加锁或解锁。
使⽤函数::acrxUnlockApplication()可以使应⽤程序不可卸载。
AcEd库提供定义和注册新的AutoCAD命令的类,新命令的操作性能与AutoCAD内部命令是完全⼀样的。
我们定义的新命令被当作本地命令是因为它们与AutoACD内部命令具有相同的内部结构(AcEdCommandStack)。
AcEd库还提供编辑器反应器和⼀套与AutoCAD通信的全局函数。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
使用ObjectARX2015开发类似outlook浮动面板窗格开发步骤如下:1.建立新项目,基于MFC类项目。
2.添加基于arx类库的浮动对话框类,添加完后,会自动生成DockControlBar和DockControlBarChildDlg文件。
3.在DockControlBarChildDlg设置CMFCOutlookBar 和CTreeCtrl变量函数。
4.运行程序,生成.arx文件,然后再AutoCAD2015中加载,效果如下:5.左侧面板中每个节点运行时可以对应一个已经开发完的arx程序,但首先应该在AutoCAD中加载这些函数。
附件:源程序DockControlBar.h// (C) Copyright 2002-2007 by Autodesk, Inc.//// Permission to use, copy, modify, and distribute this software in// object code form for any purpose and without fee is hereby granted,// provided that the above copyright notice appears in all copies and// that both that copyright notice and the limited warranty and// restricted rights notice below appear in all supporting// documentation.//// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE// UNINTERRUPTED OR ERROR FREE.//// Use, duplication, or disclosure by the U.S. Government is subject to// restrictions set forth in FAR 52.227-19 (Commercial Computer// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)// (Rights in Technical Data and Computer Software), as applicable.////-----------------------------------------------------------------------------//----- DockControlBar.h : Declaration of the CDockControlBar//-----------------------------------------------------------------------------#pragma once//-----------------------------------------------------------------------------#include"acui.h"#include"DockControlBarChildDlg.h"//-----------------------------------------------------------------------------class CDockControlBar : public CAcUiDockControlBar {DECLARE_DYNAMIC (CDockControlBar)public://----- Child dialog which will use the resource id suppliedCDockControlBarChildDlg *mChildDlg ;public:CDockControlBar ();virtual ~CDockControlBar ();public:virtual BOOL Create (CWnd *pParent, LPCTSTR lpszTitle) ;virtual void SizeChanged (CRect *lpRect, BOOL bFloating, int flags) ;virtual CSize CalcFixedLayout( BOOL bStretch , BOOL bHorz );afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct) ;afx_msg void OnSysCommand (UINT nID, LPARAM lParam) ;afx_msg void OnSize (UINT nType, int cx, int cy) ;DECLARE_MESSAGE_MAP()afx_msg void OnClose();} ;DockControlBar.cpp// (C) Copyright 2002-2007 by Autodesk, Inc.//// Permission to use, copy, modify, and distribute this software in// object code form for any purpose and without fee is hereby granted,// provided that the above copyright notice appears in all copies and// that both that copyright notice and the limited warranty and// restricted rights notice below appear in all supporting// documentation.//// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE// UNINTERRUPTED OR ERROR FREE.//// Use, duplication, or disclosure by the U.S. Government is subject to// restrictions set forth in FAR 52.227-19 (Commercial Computer// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)// (Rights in Technical Data and Computer Software), as applicable.////-----------------------------------------------------------------------------//----- DockControlBar.cpp : Implementation of CDockControlBar//-----------------------------------------------------------------------------#include"StdAfx.h"#include"resource.h"#include"DockControlBar.h"//-----------------------------------------------------------------------------IMPLEMENT_DYNAMIC (CDockControlBar, CAcUiDockControlBar)BEGIN_MESSAGE_MAP(CDockControlBar, CAcUiDockControlBar)ON_WM_CREATE()ON_WM_SYSCOMMAND()ON_WM_SIZE()ON_WM_CLOSE()END_MESSAGE_MAP()//-----------------------------------------------------------------------------//----- CDockControlBar *pInstance = new CDockControlBar;//----- pInstance->Create (acedGetAcadFrame (), "My title bar") ;//----- pInstance->EnableDocking (CBRS_ALIGN_ANY) ;//----- pInstance->RestoreControlBar () ;//-----------------------------------------------------------------------------static CLSID clsCDockControlBar = {0xeab78c04, 0x2194, 0x47ad, {0xa4, 0xf2, 0xad, 0xca, 0x3e, 0x3b, 0xb6, 0x3c}} ;//-----------------------------------------------------------------------------CDockControlBar::CDockControlBar () : CAcUiDockControlBar() {mChildDlg = NULL;}//-----------------------------------------------------------------------------CDockControlBar::~CDockControlBar () {}//-----------------------------------------------------------------------------#ifdef _DEBUG//- Please uncomment the 2 following lines to avoid linker error when compiling//- in release mode. But make sure to uncomment these lines only once per project//- if you derive multiple times from CAdUiDockControlBar/CAcUiDockControlBar//- classes.//void CAdUiDockControlBar::AssertValid () const {//}#endif//-----------------------------------------------------------------------------BOOL CDockControlBar::Create (CWnd *pParent, LPCTSTR lpszTitle) {CString strWndClass ;strWndClass =AfxRegisterWndClass (CS_DBLCLKS, LoadCursor (NULL, IDC_ARROW)) ;CRect rect (0, 0, 150, 200) ;if (!CAcUiDockControlBar::Create (strWndClass, lpszTitle, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,rect, pParent, 0))return (FALSE) ;SetToolID (&clsCDockControlBar) ;// TODO: Add your code herereturn (TRUE) ;}//-----------------------------------------------------------------------------//----- This member function is called when an application requests the window be//----- created by calling the Create or CreateEx member functionint CDockControlBar::OnCreate (LPCREATESTRUCT lpCreateStruct) {if ( CAcUiDockControlBar::OnCreate (lpCreateStruct) == -1 )return (-1) ;//----- Point to our resourceCAcModuleResourceOverride resourceOverride;//----- Create it and set the parent as the dockctrl barmChildDlg = new CDockControlBarChildDlg;mChildDlg->Create (IDD_DOCKCONTROLBAR, this) ;//----- Move the window over so we can see the control linesmChildDlg->MoveWindow (0, 0, 150, 100, TRUE) ;return (0) ;}//-----------------------------------------------------------------------------void CDockControlBar::SizeChanged (CRect *lpRect, BOOL bFloating, int flags) { // If validif (::IsWindow (mChildDlg->GetSafeHwnd ())){//----- Always point to our resource to be safeCAcModuleResourceOverride resourceOverride ;//----- Then update its window size relativelymChildDlg->SetWindowPos (this, lpRect->left + 4, lpRect->top + 4, lpRect->Width (), lpRect->Height (), SWP_NOZORDER) ;}}//-----------------------------------------------------------------------------CSize CDockControlBar::CalcFixedLayout( BOOL bStretch , BOOL bHorz ){//如果当前处于浮动状态if (IsFloating()){CRect m_r1;GetClientRect(m_r1);//m_childDlg->SetWindowPos (this, m_r1.left+2, m_r1.top, m_r1.Width (), m_r1.Height (), SWP_NOZORDER) ;return CSize(150,450);}else//处于固定状态{return CSize(150,450);}}//-----------------------------------------------------------------------------//----- Function called when user selects a command from Control menu or when user//----- selects the Maximize or the Minimize button.void CDockControlBar::OnSysCommand (UINT nID, LPARAM lParam) {CAcUiDockControlBar::OnSysCommand (nID, lParam) ;}//-----------------------------------------------------------------------------//----- The framework calls this member function after the window's size has changedvoid CDockControlBar::OnSize (UINT nType, int cx, int cy) {CAcUiDockControlBar::OnSize (nType, cx, cy) ;// If validif (::IsWindow (mChildDlg->GetSafeHwnd ())){//----- Always point to our resource to be safeCAcModuleResourceOverride resourceOverride ;//----- then update its window position relativelymChildDlg->MoveWindow (0, 0, cx, cy) ;}}void CDockControlBar::OnClose(){// TODO: Add your message handler code here and/or call defaultif (mChildDlg != NULL){DestroyWindow();}CAcUiDockControlBar::OnClose();}DockControlBarChildDlg.h// (C) Copyright 2002-2007 by Autodesk, Inc.//// Permission to use, copy, modify, and distribute this software in// object code form for any purpose and without fee is hereby granted,// provided that the above copyright notice appears in all copies and// that both that copyright notice and the limited warranty and// restricted rights notice below appear in all supporting// documentation.//// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE// UNINTERRUPTED OR ERROR FREE.//// Use, duplication, or disclosure by the U.S. Government is subject to// restrictions set forth in FAR 52.227-19 (Commercial Computer// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)// (Rights in Technical Data and Computer Software), as applicable.////-----------------------------------------------------------------------------//----- DockControlBarChildDlg.h : Declaration of the CDockControlBarChildDlg//-----------------------------------------------------------------------------#pragma once//-----------------------------------------------------------------------------#include"acui.h"//-----------------------------------------------------------------------------class CDockControlBarChildDlg : public CAcUiDialog {DECLARE_DYNAMIC (CDockControlBarChildDlg)public:CDockControlBarChildDlg (CWnd *pParent =NULL, HINSTANCE hInstance =NULL) ;enum { IDD = IDD_DOCKCONTROLBAR};public:CMFCOutlookBar m_wndOutlookBar;//CMFCOutlookBarPane m_wndOutlookPane;CTreeCtrl m_wndTree; //结构分析CTreeCtrl m_wndTree1;//工具箱CTreeCtrl m_wndTree2;//绘图CImageList Treelist;protected:virtual void DoDataExchange (CDataExchange *pDX) ;virtual BOOL OnCommand (WPARAM wParam, LPARAM lParam) ;protected:afx_msg LRESULT OnAcadKeepFocus (WPARAM wParam, LPARAM lParam) ;afx_msg void OnDblClkTree(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnDblClkTree1(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnDblClkTree2(NMHDR* pNMHDR, LRESULT* pResult); protected:DECLARE_MESSAGE_MAP()public:virtual BOOL OnInitDialog();BOOL CreateTreeControl();BOOL CreateTreeControl1();BOOL CreateTreeControl2();} ;DockControlBarChildDlg.cpp// (C) Copyright 2002-2007 by Autodesk, Inc.//// Permission to use, copy, modify, and distribute this software in// object code form for any purpose and without fee is hereby granted,// provided that the above copyright notice appears in all copies and// that both that copyright notice and the limited warranty and// restricted rights notice below appear in all supporting// documentation.//// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE// UNINTERRUPTED OR ERROR FREE.//// Use, duplication, or disclosure by the U.S. Government is subject to// restrictions set forth in FAR 52.227-19 (Commercial Computer// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)// (Rights in Technical Data and Computer Software), as applicable.////-----------------------------------------------------------------------------//- DockControlBar.cpp : Implementation of CDockControlBarChildDlg//-----------------------------------------------------------------------------#include"StdAfx.h"#include"resource.h"#include"DockControlBarChildDlg.h"#include"My_SubFunctions.h"//-----------------------------------------------------------------------------#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif//-----------------------------------------------------------------------------IMPLEMENT_DYNAMIC (CDockControlBarChildDlg, CAcUiDialog)BEGIN_MESSAGE_MAP(CDockControlBarChildDlg, CAcUiDialog)//{{AFX_MSG_MAP(CDockControlBarChildDlg)ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus) // Needed for modeless dialog.//}}AFX_MSG_MAPON_NOTIFY(NM_DBLCLK, ID_VIEW_TASKPANE_CTREE, OnDblClkTree)ON_NOTIFY(NM_DBLCLK, ID_VIEW_TASKPANE_CTREE1, OnDblClkTree1)ON_NOTIFY(NM_DBLCLK, ID_VIEW_TASKPANE_CTREE2, OnDblClkTree2)END_MESSAGE_MAP()//-----------------------------------------------------------------------------CDockControlBarChildDlg::CDockControlBarChildDlg (CWnd *pParent/*=NULL*/, HINSTANCE hInstance/*=NULL*/) : CAcUiDialog (CDockControlBarChildDlg::IDD, pParent, hInstance) { //{{AFX_DATA_INIT(CDockControlBarChildDlg)//}}AFX_DATA_INIT}//-----------------------------------------------------------------------------void CDockControlBarChildDlg::DoDataExchange (CDataExchange *pDX) {CAcUiDialog::DoDataExchange (pDX) ;//{{AFX_DATA_MAP(CDockControlBarChildDlg)//}}AFX_DATA_MAP}//-----------------------------------------------------------------------------//- Needed for modeless dialogs to keep focus.//- Return FALSE to not keep the focus, return TRUE to keep the focusLRESULT CDockControlBarChildDlg::OnAcadKeepFocus (WPARAM wParam, LPARAM lParam) { return (TRUE) ;}//-----------------------------------------------------------------------------//- As this dialog is a child dialog we need to disable ok and cancelBOOL CDockControlBarChildDlg::OnCommand (WPARAM wParam, LPARAM lParam) { switch ( wParam ) {case IDOK:case IDCANCEL:return (FALSE) ;}return (CAcUiDialog::OnCommand (wParam, lParam)) ;}BOOL CDockControlBarChildDlg::OnInitDialog(){CAcUiDialog::OnInitDialog();// TODO: Add extra initialization hereCMFCOutlookBarTabCtrl::EnableAnimation ();if (!m_wndOutlookBar.Create (_T("Shortcuts"), this,CRect(0,0,150-5,450-30),ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) {TRACE0("Failed to create outlook bar\n");return FALSE; // fail to create}CMFCOutlookBarTabCtrl* pShortcutsBarContainer = DYNAMIC_DOWNCAST(CMFCOutlookBarTabCtrl, m_wndOutlookBar.GetUnderlyingWindow ());if (pShortcutsBarContainer == NULL){TRACE0("Cannot get outlook bar container\n");return FALSE;}//***************************************if (!CreateTreeControl()){TRACE0("Failed to create the custom window\n");return -1; // fail to create}pShortcutsBarContainer->AddTab(&m_wndTree, _T("结构分析"), 0, FALSE);//***************************************if (!CreateTreeControl1()){TRACE0("Failed to create the custom window\n");return -1; // fail to create}pShortcutsBarContainer->AddTab(&m_wndTree1, _T("工具箱"), 1, FALSE);//***************************************if (!CreateTreeControl2()){TRACE0("Failed to create the custom window\n");return -1; // fail to create}pShortcutsBarContainer->AddTab(&m_wndTree2, _T("绘图"), 2, FALSE);return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}BOOL CDockControlBarChildDlg::CreateTreeControl(){Treelist.Create(16,16,ILC_COLOR32|ILC_MASK,0,0);Treelist.Add(::AfxGetApp()->LoadIconW(IDI_ICON_XY));Treelist.Add(::AfxGetApp()->LoadIconW(IDI_ICON_XY));CRect rectDummy (0, 0, 0, 0);const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES |TVS_LINESATROOT | TVS_HASBUTTONS;if(!m_wndTree.Create (dwTreeStyle, rectDummy, this, ID_VIEW_TASKPANE_CTREE)){TRACE0("Failed to create the custom window\n");return FALSE;}m_wndTree.SetImageList(&Treelist,TVSIL_NORMAL);HTREEITEM tree;m_wndTree.ModifyStyle(NULL,TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS);tree=m_wndTree.InsertItem(_T("结构静力计算"),0,0); //"0"为项的图像在tree view控件的图像列表中的索引。