【转载】双击实体弹出对话框(重载AcDbDoubleClickEdit)
代码语言:javascript复制// DoubleClickEdit.h: interface for the CDoubleClickEdit class.
//
//
//By freejsutin 2005-08-17
#include "AcDblClkEdit.h" //for dinfine AcDbDoubleClickEdit
#pragma comment (lib ,"AcDblClkEditPE.lib")
#include "actrans.h" //for dinfine actrTransactionManager
class CDoubleClickEdit : public AcDbDoubleClickEdit
{
public:
CDoubleClickEdit();
virtual ~CDoubleClickEdit();
void finishEdit(void);
void CDoubleClickEdit::startEdit(AcDbEntity *pEnt, AcGePoint3d clickpt);
private:
bool upgradeOpen(AcDbObject *pEnt);
};
// DoubleClickEdit.cpp: implementation of the CDoubleClickEdit class. // //
代码语言:javascript复制#include "stdafx.h"
#include "autodrawing.h"
#include "DoubleClickEdit.h"
#include "DeviceAttribute.h"
void CDoubleClickEdit::finishEdit()
{
}// 主要是这个函数在起作用,在这个函数里实现你想要的功能
代码语言:javascript复制void CDoubleClickEdit::startEdit(AcDbEntity *pEnt, AcGePoint3d clickpt)
{
// 由于要对实体进行编辑,先锁定文档
AcApDocument *pDoc = acDocManager->curDocument();
acDocManager->lockDocument(pDoc, AcAp::kWrite);
// 判断如果传进来的实体是我的自定义实体,便进行修改操作
if (pEnt->isKindOf(cascoCDeviceDrawing::desc()))
{
cascoCDeviceDrawing* pMyClass = cascoCDeviceDrawing::cast(pEnt);
// 将打开级别升级到可写方式,防止对象以只读模式打开
if( !upgradeOpen(pMyClass) )
{
acDocManager->unlockDocument(pDoc);
return;
}
// 创建这个对象,以便切换CAD资源
CAcModuleResourceOverride thisResource;
CDeviceAttribute Diatest(CWnd::FromHandle(adsw_acadMainWnd()));
Diatest.DoModal();
pMyClass->close();
}
// 所有修改完成,解锁文档
acDocManager->unlockDocument(pDoc);
// 刷新显示
actrTransactionManager->flushGraphics();
}
bool CDoubleClickEdit::upgradeOpen(AcDbObject *pEnt)
{
if(pEnt->upgradeOpen()!=Acad::eOk)
{
acutPrintf("错误:不能打开%s实体!", pEnt->isA()->name());
return FALSE;
}
return TRUE;
}