《使用ObjectARX2015开发类似outlook浮动面板窗格资料11632.pdf》由会员分享,可在线阅读,更多相关《使用ObjectARX2015开发类似outlook浮动面板窗格资料11632.pdf(25页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、使用ObjectARX2015 开发类似outlook 浮动面板窗格 开发步骤如下:1建立新项目,基于 MFC 类项目。2添加基于 arx 类库的浮动对话框类,添加完后,会自动生成DockControlBar和DockControlBarChildDlg文件。3在 DockControlBarChildDlg 设置CMFCOutlookBar 和 CTreeCtrl 变量函数。4运行程序,生成.arx 文件,然后再 AutoCAD2015中加载,效果如下:5左侧面板中每个节点运行时可以对应一个已经开发完的arx 程序,但首先应该在 AutoCAD 中加载这些函数。附件:源程序 DockCont
2、rolBar.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 warr
3、anty 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
4、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./-/-Do
5、ckControlBar.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 supplied CDockControlBarChildDlg*mChildDlg;publi
6、c: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 OnSysComma
7、nd(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 gr
8、anted,/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 AN
9、Y 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/S
10、oftware-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)BEG
11、IN_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()
12、;/-static CLSID clsCDockControlBar=0 xeab78c04,0 x2194,0 x47ad,0 xa4,0 xf2,0 xad,0 xca,0 x3e,0 x3b,0 xb6,0 x3c;/-CDockControlBar:CDockControlBar():CAcUiDockControlBar()mChildDlg=NULL;/-CDockControlBar:CDockControlBar()/-#ifdef _DEBUG/-Please uncomment the 2 following lines to avoid linker error when
13、 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 strWn
14、dClass;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 here return(TRUE);/-/-This me
15、mber function is called when an application requests the window be /-created by calling the Create or CreateEx member function int CDockControlBar:OnCreate(LPCREATESTRUCT lpCreateStruct)if(CAcUiDockControlBar:OnCreate(lpCreateStruct)=-1)return(-1);/-Point to our resource CAcModuleResourceOverride re
16、sourceOverride;/-Create it and set the parent as the dockctrl bar mChildDlg=new CDockControlBarChildDlg;mChildDlg-Create(IDD_DOCKCONTROLBAR,this);/-Move the window over so we can see the control lines mChildDlg-MoveWindow(0,0,150,100,TRUE);return(0);/-void CDockControlBar:SizeChanged(CRect*lpRect,BO
17、OL bFloating,int flags)/If valid if(:IsWindow(mChildDlg-GetSafeHwnd()/-Always point to our resource to be safe CAcModuleResourceOverride resourceOverride;/-Then update its window size relatively mChildDlg-SetWindowPos(this,lpRect-left+4,lpRect-top+4,lpRect-Width(),lpRect-Height(),SWP_NOZORDER);/-CSi
18、ze 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 sel
19、ects 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 windows size has changed void CDockControlBar:OnSiz
20、e(UINT nType,int cx,int cy)CAcUiDockControlBar:OnSize(nType,cx,cy);/If valid if(:IsWindow(mChildDlg-GetSafeHwnd()/-Always point to our resource to be safe CAcModuleResourceOverride resourceOverride;/-then update its window position relatively mChildDlg-MoveWindow(0,0,cx,cy);void CDockControlBar:OnCl
21、ose()/TODO:Add your message handler code here and/or call default if(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 with
22、out 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 SPECI
23、FICALLY 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(C
24、ommercial 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 DECL
25、ARE_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;/绘图 CImageLis
26、t 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*pResu
27、lt);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
28、,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
29、./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 t
30、he 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#i
31、nclude resource.h#include DockControlBarChildDlg.h#include My_SubFunctions.h /-#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILE static char THIS_FILE=_FILE_;#endif /-IMPLEMENT_DYNAMIC(CDockControlBarChildDlg,CAcUiDialog)BEGIN_MESSAGE_MAP(CDockControlBarChildDlg,CAcUiDialog)/AFX_MSG_MAP(CDockContro
32、lBarChildDlg)ON_MESSAGE(WM_ACAD_KEEPFOCUS,OnAcadKeepFocus)/Needed for modeless dialog./AFX_MSG_MAP ON_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()/-CDockContr
33、olBarChildDlg: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);/A
34、FX_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 focus LRESULT CDockControlBarChildDlg:OnAcadKeepFocus(WPARAM wParam,LPARAM lParam)return(TRUE);/-/-As this dialog is a child dialog we need to
35、disable ok and cancel BOOL 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 here CMFCOutlo
36、okBarTabCtrl: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 barn);return FALSE;/fail to create CMFCOutlookBarTabCtrl*pShortcutsBarContainer=DYNAMIC_DOWNCAST(CMFCOutlookBarTabCtrl
37、,m_wndOutlookBar.GetUnderlyingWindow();if(pShortcutsBarContainer=NULL)TRACE0(Cannot get outlook bar containern);return FALSE;/*if(!CreateTreeControl()TRACE0(Failed to create the custom windown);return-1;/fail to create pShortcutsBarContainer-AddTab(&m_wndTree,_T(结构分析),0,FALSE);/*if(!CreateTreeContro
38、l1()TRACE0(Failed to create the custom windown);return-1;/fail to create pShortcutsBarContainer-AddTab(&m_wndTree1,_T(工具箱),1,FALSE);/*if(!CreateTreeControl2()TRACE0(Failed to create the custom windown);return-1;/fail to create pShortcutsBarContainer-AddTab(&m_wndTree2,_T(绘图),2,FALSE);return TRUE;/re
39、turn 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 re
40、ctDummy(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 windown);return FALSE;m_wndTree.SetImageList(&Treelist,TVSIL_NORMAL);HTREEITEM tree;m_wnd
41、Tree.ModifyStyle(NULL,TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS);tree=m_wndTree.InsertItem(_T(结构静力计算),0,0);/0为项的图像在tree view控件的图像列表中的索引。m_wndTree.InsertItem(_T(矩阵位移法),1,1,tree);m_wndTree.Expand(tree,TVE_EXPAND);/必须反复调用,因为tree一直在变化。m_wndTree.RedrawWindow();return TRUE;BOOL CDockControlBarChildDlg:C
42、reateTreeControl1()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_wndTree1.Create(
43、dwTreeStyle,rectDummy,this,ID_VIEW_TASKPANE_CTREE1)TRACE0(Failed to create the custom windown);return FALSE;m_wndTree1.SetImageList(&Treelist,TVSIL_NORMAL);HTREEITEM tree;m_wndTree1.ModifyStyle(NULL,TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS);tree=m_wndTree1.InsertItem(_T(钢结构),0,0);/0为项的图像在tree vie
44、w控件的图像列表中的索引。m_wndTree1.InsertItem(_T(截面特性),1,1,tree);m_wndTree1.Expand(tree,TVE_EXPAND);/必须反复调用,因为tree一直在变化。m_wndTree1.RedrawWindow();return TRUE;BOOL CDockControlBarChildDlg:CreateTreeControl2()Treelist.Create(16,16,ILC_COLOR32|ILC_MASK,0,0);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_XY);Treelis
45、t.Add(:AfxGetApp()-LoadIconW(IDI_ICON_BROKEN);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_COLUMN);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_QUALITY);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_FUHAO);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_CODE);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON
46、_MEASURE);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_TABLE);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_SECTION);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_AREA);Treelist.Add(:AfxGetApp()-LoadIconW(IDI_ICON_HEIGHT);CRect rectDummy(0,0,0,0);const DWORD dwTreeStyle=WS_CHILD|WS_VISIBLE|TVS_HASLINE
47、S|TVS_LINESATROOT|TVS_HASBUTTONS;if(!m_wndTree2.Create(dwTreeStyle,rectDummy,this,ID_VIEW_TASKPANE_CTREE2)TRACE0(Failed to create the custom windown);return FALSE;m_wndTree2.SetImageList(&Treelist,TVSIL_NORMAL);HTREEITEM treeXY,treeCode,treeMeasure;m_wndTree2.ModifyStyle(NULL,TVS_HASLINES|TVS_LINESA
48、TROOT|TVS_HASBUTTONS);treeXY=m_wndTree2.InsertItem(_T(XY图),0,0);/0为项的图像在tree view控件的图像列表中的索引。m_wndTree2.InsertItem(_T(折线图),1,1,treeXY);m_wndTree2.InsertItem(_T(柱状图),2,2,treeXY);m_wndTree2.InsertItem(_T(QC缺陷统计图),3,3,treeXY);m_wndTree2.Expand(treeXY,TVE_EXPAND);treeCode=m_wndTree2.InsertItem(_T(符号),4,
49、4);/0为项的图像在tree view控件的图像列表中的索引。m_wndTree2.InsertItem(_T(符号外框),5,5,treeCode);m_wndTree2.Expand(treeCode,TVE_EXPAND);treeMeasure=m_wndTree2.InsertItem(_T(测量数据图),6,6);/0为项的图像在tree view控件的图像列表中的索引。m_wndTree2.InsertItem(_T(坐标表),7,7,treeMeasure);m_wndTree2.InsertItem(_T(剖面图),8,8,treeMeasure);m_wndTree2.I
50、nsertItem(_T(开挖量),9,9,treeMeasure);m_wndTree2.InsertItem(_T(修改高程),10,10,treeMeasure);m_wndTree2.Expand(treeMeasure,TVE_EXPAND);m_wndTree2.RedrawWindow();return TRUE;void CDockControlBarChildDlg:OnDblClkTree(NMHDR*pNMHDR,LRESULT*pResult)HTREEITEM tree=m_wndTree.GetSelectedItem();if(!m_wndTree.GetChil