当前位置:网站首页>2021-10-13arx

2021-10-13arx

2022-07-28 10:15:00 vv1025

【 Reprint 】 Double click the entity to pop up the dialog box ( heavy load 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);
};

// DoubleClickEdit.cpp: implementation of the CDoubleClickEdit class.
//
//

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

#include "DeviceAttribute.h"

void CDoubleClickEdit::finishEdit()
{

}//  It's mainly this function that works , Realize the function you want in this function 
void CDoubleClickEdit::startEdit(AcDbEntity *pEnt, AcGePoint3d clickpt)
{
//  Because you want to edit the entity , Lock the document first 
AcApDocument *pDoc = acDocManager->curDocument();
acDocManager->lockDocument(pDoc, AcAp::kWrite);

//  Judge if the entity passed in is my user-defined entity , Then modify 
if (pEnt->isKindOf(cascoCDeviceDrawing::desc())) 
{
   cascoCDeviceDrawing* pMyClass = cascoCDeviceDrawing::cast(pEnt);

   //  Upgrade the opening level to writable , Prevent objects from being opened in read-only mode 
   if( !upgradeOpen(pMyClass) ) 
   {
            acDocManager->unlockDocument(pDoc);
    return;
   }

   //  Create this object , In order to switch CAD resources 
   CAcModuleResourceOverride thisResource;

   CDeviceAttribute Diatest(CWnd::FromHandle(adsw_acadMainWnd()));
   Diatest.DoModal();

   pMyClass->close();

}

//  All modifications are completed , Unlock document 
acDocManager->unlockDocument(pDoc);
//  Refresh the display 
actrTransactionManager->flushGraphics();
}

bool CDoubleClickEdit::upgradeOpen(AcDbObject *pEnt)
{
if(pEnt->upgradeOpen()!=Acad::eOk)
{
   acutPrintf(" error : Can't open %s Entity !", pEnt->isA()->name());
   return FALSE;
}
return TRUE;
}

原网站

版权声明
本文为[vv1025]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/209/202207280953395020.html