54syt 发表于 2008-4-10 13:41:00

appContextNewDocument() 和 appContextOpenDocument()

本帖最后由 作者 于 2008-4-10 13:56:24 编辑 <br /><br /> <p>我从ObjectARX 2008的 例子 docman project 拷贝了几个函数如下:<br/>void newSyncDocHelper( void *pData)<br/>{<br/>&nbsp; &nbsp; if (acDocManager-&gt;isApplicationContext()) {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;const TCHAR * fileName = (const TCHAR *)pData;<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Acad::ErrorStatus es = acDocManager-&gt;appContextNewDocument(fileName);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;assert(es == Acad::eOk);<br/>&nbsp; &nbsp; }<br/>&nbsp; &nbsp; else<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;assert(0 &amp;&amp; "\nERROR: in Document context");<br/>}<br/><br/>void openSyncDocHelper( void *pData)<br/>{<br/>&nbsp; &nbsp; if (acDocManager-&gt;isApplicationContext()) {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;const TCHAR * fileName = (const TCHAR *)pData;<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Acad::ErrorStatus es = acDocManager-&gt;appContextOpenDocument(fileName);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;assert(es == Acad::eOk);<br/>&nbsp; &nbsp; } <br/>&nbsp; &nbsp; else<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;assert(0 &amp;&amp; "ERROR: in Document context.");<br/>}<br/><br/><br/><br/>openSyncDoc()<br/>{<br/>&nbsp; &nbsp; static TCHAR pData[] = _T(/*NOXLATE*/"test1.dwg");<br/><br/>&nbsp; &nbsp; AcApDocument* pDoc = acDocManager-&gt;curDocument();<br/>&nbsp; &nbsp; if (pDoc) {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;acutPrintf(_T("\nCurrently in Document context : %s, Switching to App.\n"),pDoc-&gt;fileName());<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;acDocManager-&gt;executeInApplicationContext(openSyncDocHelper, (void *)pData);<br/>&nbsp; &nbsp; } <br/>}<br/><br/>void<br/>newSyncDoc()<br/>{<br/>&nbsp; &nbsp; static TCHAR pData[] = _T(/*NOXLATE*/"acad.dwt");<br/><br/>&nbsp; &nbsp; AcApDocument* pDoc = acDocManager-&gt;curDocument();<br/>&nbsp; &nbsp; if (pDoc) {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;acutPrintf(_T("\nCurrently in Document context : %s, Switching to App.\n"),pDoc-&gt;fileName());<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;acDocManager-&gt;executeInApplicationContext(newSyncDocHelper, (void *)pData);<br/>&nbsp; &nbsp; } <br/>}<br/>当我在我的项目里面用这几个函数时, 当调用 openSyncDoc()时 acDocManager-&gt;appContextOpenDocument()是正常的返回Acad::eOK.<br/>但调用newSyncDoc()时 acDocManager-&gt;appContextNewDocument()返回的却一直是Acad::eFilerError. 不知道是怎么回事。<br/>Can you help me?&nbsp;&nbsp;thanks.<br/></p>
页: [1]
查看完整版本: appContextNewDocument() 和 appContextOpenDocument()