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")) == 0 || _tcscmp(pGlobalCmdName,_T("SAVEAS"))==0)
  {
    if(...)//判斷是否需要取消保存或者另存爲命令
    {
        acutPrintf(_T("\n禁止保存或另存爲操作!\n"));
        Acad::ErrorStatus es = veto();
    }
  }
  AcApDocManagerReactor::documentLockModeChanged (param2, myPreviousMode, myCurrentMode, currentMode, pGlobalCmdName) ;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章