天天看點

objectarx阻止cad指令

詳見:

利用編輯反應器截獲到指令後如何取消這個指令?

http://bbs.xdcad.net/thread-706107-1-1.html

(出處: 曉東CAD家園-論壇)

你要阻止一個内部的ACAD指令執行,需要在AcApDocManagerReactor::documentLockModeChanged()期間,用veto()方法,除了終止,你甚至還可以建立一個你自己的SAVEAS等等。

AcApDocManagerReactor::veto Function

Acad::ErrorStatus

veto();

This function can be called during a documentLockModeChanged() callback if it is a callback for a lock request. The result will be that the lock request will be vetoed, which normally means that the command will be cancelled before it can start. When this function is called, documentLockModeChangeVetoed() will be sent.

If this is called during any other callback, or during an unlock request, it returns eNotApplicable.

It is only active during documentLockModeChanged() in case the receiver of the call needs to make any changes in the document before deciding whether to veto or not. By waiting until the changed callback, the document will be currently locked when the ability to veto is given. This is necessary because it is not possible to change the document抯 lock status from within any of these callbacks.

void Stop::documentLockModeChanged(AcApDocument * param2, AcAp::DocLockMode myPreviousMode, AcAp::DocLockMode myCurrentMode, AcAp::DocLockMode currentMode, const ACHAR * pGlobalCmdName)
{
  if (_tcscmp(pGlobalCmdName,_T("QSAVE")) ==  || _tcscmp(pGlobalCmdName,_T("SAVEAS"))==)
  {
    if(...)//判斷是否需要取消儲存或者另存為指令
    {
        acutPrintf(_T("\n禁止儲存或另存為操作!\n"));
        Acad::ErrorStatus es = veto();
    }
  }
  AcApDocManagerReactor::documentLockModeChanged (param2, myPreviousMode, myCurrentMode, currentMode, pGlobalCmdName) ;
}