#include <windows.h> // define _T as defined in MFC, to conditionally compile for unicode/mbcs #ifndef _T #ifdef UNICODE #define _T(x) L ## x #else #define _T(x) x #endif #endif //---------------------------------------- // SDS includes and imports--------------- #include "sds.h" #pragma comment(lib, "sds.lib") // --------------------------------------- // DWGDIRECT includes and imports--------- #define _TOOLKIT_IN_DLL_ // you can add this to your project's preprocessor definitions, it is put here so you don't miss it. #include "OdaCommon.h" #include "RxObject.h" #include "RxModule.h" #include "RxDynamicModule.h" #pragma comment (lib ,"DD_Root_dll.lib") //---------------------------------------- typedef struct { wchar_t *func_name; int (*func)(void); } func_entry; #define ARRAYELEMENTS(array) (sizeof(array)/sizeof((array)[0])) extern int Test1(); extern int Test2(); static func_entry func_table[] = { { L"test1", Test1 }, { L"test2", Test2 }, }; static bool funcload() { int i; for (i=0; i<ARRAYELEMENTS(func_table); i++) if (!sds_defun(func_table[i].func_name, i)) return false; return true; } static bool invokefun() { int val; val = sds_getfuncode(); if ((val<0) || (val>=ARRAYELEMENTS(func_table))) return false; int rc = (*func_table[val].func)(); return (rc==RTNORM); } // class derived from OdRxModule, necessary to be loaded in Bricscad ---- class MyDrxModule : public OdRxModule { protected: MyDrxModule() {} void initApp() {} void uninitApp() {} public: ~MyDrxModule() {} }; ODRX_DEFINE_DYNAMIC_MODULE(MyDrxModule); // -------------------------------------------------------------------- // acrxEntryPoint : not mandatory, only really necessary if you're using sds_defun.-- extern "C" __declspec(dllexport) AcRx::AppRetCode acrxEntryPoint( AcRx::AppMsgCode msg, void* appId) { switch( msg ) { case AcRx::kInitAppMsg: break; case AcRx::kUnloadAppMsg: break; case AcRx::kLoadDwgMsg: if ( !funcload() ) return AcRx::kRetError; break; case AcRx::kUnloadDwgMsg: break; case AcRx::kInvkSubrMsg: if ( !invokefun() ) return AcRx::kRetError; break; case AcRx::kSaveMsg: break; case AcRx::kQuitMsg: break; case AcRx::kPreQuitMsg: break; case AcRx::kCfgMsg: break; default: break; } return AcRx::kRetOK; } |