马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
AcApDocManager::disableDocumentActivation() doesn't work after save & close document
By Philippe Leefsma
问题:
AcApDocManager::disableDocumentActivation() should disable switching documents, opening new documents and closing documents. Usually, it does all this. However, if when saving the current document (eg. SAVE from command line), it is possible to directly close (fe. CLOSE from command line) the current document after that. Also opening a new document immediately after a SAVE is doable.
How can to make it work after SAVE?
解答:
A workaround is to use AcEditorReactor and override commandEnded(). In it, you can check if the command is 'qsave' or 'save', if it is, call AcApDocManager::disableDocumentActivation() again (it is first called it in the acrxEntryPoint()).
-
- class CMyEditorReactor : public AcEditorReactor
- {
- public:
- void commandEnded(const ACHAR *pCmdStr)
- {
- if(_tcsicmp(pCmdStr, _T("qsave")) == 0 ||
- _tcsicmp(pCmdStr, _T("save")) == 0)
- acDocManagerPtr()->disableDocumentActivation();
- }
- };
- CMyEditorReactor *gpMyEdReactor = NULL;
- //------------------------------------------------------------------
- //----- ObjectARX EntryPoint
- class CdisableDocumentActivationApp : public AcRxArxApp {
- public:
- CdisableDocumentActivationApp () : AcRxArxApp () {}
- virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt)
- {
- AcRx::AppRetCode retCode =
- AcRxArxApp::On_kInitAppMsg (pkt) ;
- acDocManagerPtr()->disableDocumentActivation();
- gpMyEdReactor = new CMyEditorReactor();
- acedEditor->addReactor(gpMyEdReactor);
- return (retCode) ;
- }
- virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt)
- {
- AcRx::AppRetCode retCode =
- AcRxArxApp::On_kUnloadAppMsg (pkt) ;
- if(acDocManagerPtr())
- acDocManagerPtr()->enableDocumentActivation();
- if(gpMyEdReactor)
- {
- acedEditor->removeReactor(gpMyEdReactor);
- delete gpMyEdReactor;
- }
- return (retCode) ;
- }
- virtual void RegisterServerComponents () {
- }
- } ;
- //------------------------------------------------------------------
- IMPLEMENT_ARX_ENTRYPOINT(CdisableDocumentActivationApp)
|