admin 发表于 2024-2-28 08:57:30

双击实体弹出对话框(重载AcDbDoubleClickEdit)

// 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);
};

admin 发表于 2024-2-28 08:57:55

DoubleClickEdit.cpp: implementation of the CDoubleClickEdit class.

#include "stdafx.h"
#include "autodrawing.h"
#include "DoubleClickEdit.h"

#include "DeviceAttribute.h"

void CDoubleClickEdit::finishEdit()
{

}// 主要是这个函数在起作用,在这个函数里实现你想要的功能

admin 发表于 2024-2-28 08:58:05

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;
}
页: [1]
查看完整版本: 双击实体弹出对话框(重载AcDbDoubleClickEdit)