您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 基于objectarx二次开发在autocad中实现QQ抽屉效果
基于objectarx二次开发在autocad中实现QQ抽屉效果操作步骤:1.在vs2005中创建一个基于objectarx的应用程序,程序名为:WPJ-STRUCTURE。2.添加基于CAcUiDockControlBar的类CDockControlBar,添加后,程序会增加类文件“DockControlBarChildDlg.h”和“DockControlBarChildDlg.cpp”,并在资源中自动添加ID为“IDD_DOCKCONTROLBAR”的对话框面板,同时生成类文件“DockControlBarChildDlg.h”和“DockControlBarChildDlg.cpp”。3.添加GfxGroupEdit.cpp、GfxGroupEdit.h、GfxPopupMenu.cpp、GfxPopupMenu.h、GfxOutBarCtrl.cpp、GfxOutBarCtrl.h到工程中,在文件GfxGroupEdit.cpp和GfxPopupMenu.cpp中添加如下代码:#includeDockControlBarChildDlg.h。4.在资源文件中导入三个光标文件,分别命名其ID为:IDC_DRAGGING、IDC_HANDCUR、IDC_NODRAGGING;并添加Icon资源,分别命名其ID为:ID_GFX_LARGEICON、ID_GFX_REMOVEITEM、ID_GFX_RENAMEITEM、ID_GFX_SMALLICON。5.在“DockControlBarChildDlg.h”文件中添加:#defineIDC_LST_MENUWM_USER+1000#includeresource.h#includeGfxOutBarCtrl.h6.在“DockControlBarChildDlg.h”文件中添加变量:CGfxOutBarCtrlwndBar;7.在“DockControlBarChildDlg.h”文件中添加消息函数:afx_msglongOnOutbarNotify(WPARAMwParam,LPARAMlParam);8.在“DockControlBarChildDlg.cpp”文件中添加代码:ON_MESSAGE(WM_OUTBAR_NOTIFY,OnOutbarNotify)9.在“DockControlBarChildDlg.cpp”文件中添加OnOutbarNotify函数具体代码:longCDockControlBarChildDlg::OnOutbarNotify(WPARAMwParam,LPARAMlParam){switch(wParam){caseNM_OB_ITEMCLICK://castthelParamtoanintegertogettheclickeditem{intindex=(int)lParam;CStringcs,cs1;cs1=wndBar.GetItemText(index);intiFloder=wndBar.GetSelFolder();cs.Format(_T(Clickedon%dFloder-%d::%s),iFloder,(int)lParam,cs1);AfxMessageBox(cs);}return0;caseNM_OB_ONLABELENDEDIT://castthelParamtoanOUTBAR_INFO*struct;itwillcontaininfoabouttheediteditem//return1todothechangeand0tocancelit{OUTBAR_INFO*pOI=(OUTBAR_INFO*)lParam;TRACE2(_T(Editingitem%d,newtext:%s\n),pOI-index,pOI-cText);}return1;caseNM_OB_ONGROUPENDEDIT://castthelParamtoanOUTBAR_INFO*struct;itwillcontaininfoabouttheeditedfolder//return1todothechangeand0tocancelit{OUTBAR_INFO*pOI=(OUTBAR_INFO*)lParam;TRACE2(_T(Editingfolder%d,newtext:%s\n),pOI-index,pOI-cText);}return1;caseNM_OB_DRAGITEM://castthelParamtoanOUTBAR_INFO*struct;itwillcontaininfoaboutthedraggeditems//return1todothechangeand0tocancelit{OUTBAR_INFO*pOI=(OUTBAR_INFO*)lParam;TRACE2(_T(Dragitem%datposition%d\n),pOI-iDragFrom,pOI-iDragTo);}return1;}return0;}10.在“DockControlBarChildDlg.cpp”文件中添加抽屉控件的初始化代码:DWORDdwf=CGfxOutBarCtrl::fDragItems|CGfxOutBarCtrl::fEditGroups|CGfxOutBarCtrl::fEditItems|CGfxOutBarCtrl::fRemoveGroups|CGfxOutBarCtrl::fRemoveItems|CGfxOutBarCtrl::fAddGroups|CGfxOutBarCtrl::fAnimation;wndBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,150-5,450-30),this,IDC_LST_MENU,dwf);wndBar.SetOwner(this);wndBar.AddFolder(_T(Folder1),0);wndBar.AddFolder(_T(Folder2),1);wndBar.AddFolder(_T(Folder3),2);wndBar.AddFolder(_T(Folder4),3);wndBar.SetSelFolder(1);wndBar.SetIfQueryRemove(true);11.最终在autocad2007下的运行效果:附件:源代码GfxGroupEdit.h//Copyright(c)IuriApollonio1998//Use&modifyasyouwant&need,andleavethose4lines.//StronglybasedonarticleInplaceeditcontrolofMarioContestabileandEditablesubitemsofZafir//!defined(AFX_GFXGROUPEDIT_H__CA5BB022_1277_11D2_843A_0000B43382FE__INCLUDED_)#defineAFX_GFXGROUPEDIT_H__CA5BB022_1277_11D2_843A_0000B43382FE__INCLUDED_#if_MSC_VER=1000#pragmaonce#endif//_MSC_VER=1000//GfxGroupEdit.h:headerfile/////////////////////////////////////////////////////////////////////////////////CGfxGroupEditwindowclassCGfxGroupEdit:publicCEdit{//Constructionpublic:CGfxGroupEdit();//Attributespublic:BOOLbEscapeKey;CStringtext;WPARAMmsgSend;boolbNoDown;//Operationspublic://Overrides//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CGfxGroupEdit)public:virtualBOOLPreTranslateMessage(MSG*pMsg);protected:virtualvoidPostNcDestroy();//}}AFX_VIRTUAL//Implementationpublic:intiIndex;virtual~CGfxGroupEdit();//Generatedmessagemapfunctionsprotected://{{AFX_MSG(CGfxGroupEdit)afx_msgvoidOnKillFocus(CWnd*pNewWnd);afx_msgintOnCreate(LPCREATESTRUCTlpCreateStruct);afx_msgvoidOnChar(UINTnChar,UINTnRepCnt,UINTnFlags);//}}AFX_MSGDECLARE_MESSAGE_MAP()};///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}//MicrosoftDeveloperStudiowillinsertadditionaldeclarationsimmediatelybeforethepreviousline.#endif//!defined(AFX_GFXGROUPEDIT_H__CA5BB022_1277_11D2_843A_0000B43382FE__INCLUDED_)GfxGroupEdit.cpp//Copyright(c)IuriApollonio1998//Use&modifyasyouwant&need,andleavethose4lines.//StronglybasedonarticleInplaceeditcontrolofMarioContestabileandEditablesubitemsofZafir//:implementationfile//#includestdafx.h#includeDockControlBarChildDlg.h#includeGfxGroupEdit.h#includeGfxOutBarCtrl.h#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CGfxGroupEditCGfxGroupEdit::CGfxGroupEdit(){bEscapeKey=FALSE;iIndex=-1;msgSend=NM_OB_ONGROUPENDEDIT;bNoDown=false;}CGfxGroupEdit::~CGfxGroupEdit(){}BEGIN_MESSAGE_MAP(CGfxGroupEdit,CEdit)//{{AFX_MSG_MAP(CGfxGroupEdit)ON_WM_KILLFOCUS()ON_WM_CREATE()ON_WM_CHAR()//}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////
本文标题:基于objectarx二次开发在autocad中实现QQ抽屉效果
链接地址:https://www.777doc.com/doc-2534657 .html