//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
//-----------------------------------------------------------------------------
#define szRDS _RXST("")
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CTestOpenApp : public AcRxArxApp {
public:
CTestOpenApp() : AcRxArxApp() {}
virtual AcRx::AppRetCode On_kInitAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kInitAppMsg(pkt);
return (retCode);
}
virtual AcRx::AppRetCode On_kUnloadAppMsg(void *pkt) {
AcRx::AppRetCode retCode = AcRxArxApp::On_kUnloadAppMsg(pkt);
return (retCode);
}
virtual void RegisterServerComponents() { }
static void openDocHelper(void *pData)
{
if (acDocManager->isApplicationContext())
{
const TCHAR * fileName = (const TCHAR *)pData;
acutPrintf(TEXT("\nFile Name: %s"), fileName);
Acad::ErrorStatus es = acDocManager->appContextOpenDocument(fileName);
if (es != Acad::eOk)
acutPrintf(TEXT("\nout ERROR: %s\n"), acadErrorStatusText(es));
}
else
acutPrintf(TEXT("\nout ERROR: in Document context :%s\n"),
acDocManager->curDocument()->fileName());
}
static void OpenDwg1(CString strFileName)
{
if (acDocManager->isApplicationContext())
{
Acad::ErrorStatus es = acDocManager->appContextOpenDocument(strFileName);
if (es != Acad::eOk)
acutPrintf(TEXT("\nin ERROR: %s\n"), acadErrorStatusText(es));
}
else
acDocManager->executeInApplicationContext(openDocHelper, &strFileName);
}
static void OpenDwg2(CString strFileName)
{
if (acDocManager->isApplicationContext())
{
Acad::ErrorStatus es = acDocManager->appContextOpenDocument(strFileName);
if (es != Acad::eOk)
acutPrintf(TEXT("\nin ERROR: %s\n"), acadErrorStatusText(es));
}
else
acDocManager->executeInApplicationContext(openDocHelper,
const_cast<TCHAR *>(strFileName.GetString()));
}
static void MyGroupTest1()
{
OpenDwg1(CString(TEXT("C:\\Temp\\test.dwg")));
}
static void MyGroupTest2()
{
OpenDwg2(CString(TEXT("C:\\Temp\\test.dwg")));
}
};
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CTestOpenApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CTestOpenApp, MyGroup, Test1, Test1, ACRX_CMD_MODAL, NULL)
ACED_ARXCOMMAND_ENTRY_AUTO(CTestOpenApp, MyGroup, Test2, Test2, ACRX_CMD_MODAL, NULL)