// Add this resource to your MDL project (e.g. myappdll.r) #pragma Ident "MYAPP: DLL resource" /*----------------------------------------------------------------------+ | | | Include Files | | | +----------------------------------------------------------------------*/ #include #include enum DllResourceIDs { DLLMDLAPP_MYAPP = 1, }; DllMdlApp DLLMDLAPP_MYAPP = { // MDL Application name VC++ DLL in MDLAPPS or %PATH% "MYAPP", "MYAPP.DLL" }; // MYAPPCommands.cpp // Here's what your DLL entry point looks like, along with the new command table structure: extern "C" { #include "tablecmd.h" #include "MYAPPCommands.h" #include #include #include #include // MRITERATE_Root ... #include #include #include #include #include // MDL public variables #include #if !defined (mdl) // Alias for ustnTaskId if compiling .c extern char* ustnTaskIdP; #endif MYAPP_VARS g_globalVars; ///////////////////////////////////////////////////////////////////////////// // Application command table MdlCommandNumber commandNumbers [] = { // Exit command {command_unloadMdlApplication, CMD_MYAPP_FILE_EXIT }, // This table must be NULL-terminated 0 }; ///////////////////////////////////////////////////////////////////////////// // Exit command void command_unloadMdlApplication (char* unused) { mdlInput_sendCommand (CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), INPUTQ_EOQ, ustnTaskIdP, 0); } ///////////////////////////////////////////////////////////////////////////// // DLLEXPORT int MdlMain required and called by MicroStation DLLEXPORT int MdlMain ( int argc, char *argv[] ) { //See MFC documentation about AFX_MANAGE_STATE AFX_MANAGE_STATE (::AfxGetStaticModuleState ()); RscFileHandle hRscFile; memset (&g_globalVars, 0x00, sizeof (ANDRE_VARS)); SetDefaultPrefs (); // Attach MDL resources if (SUCCESS == mdlResource_openFile (&hRscFile, NULL, TRUE)) { } else { // Unload this application mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), TRUE); return ERROR; } // Load the command table if (NULL == mdlParse_loadCommandTable (NULL)) { mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), TRUE); } // Register command numbers int status = mdlSystem_registerCommandNumbers (commandNumbers); if (SUCCESS != status) { mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), TRUE); } // Register command string IDs mdlState_registerStringIds (MESSAGELISTID_Commands, MESSAGELISTID_Prompts); // Ensure that XML is installed if (!xml_determineIfMSXML4isInstalled ()) { mdlDialog_cmdNumberQueue (FALSE, CMD_MDL_UNLOAD, mdlSystem_getCurrTaskID (), TRUE); } // Register this DLL with MicroStation system events mdlSystem_setFunction (SYSTEM_RELOAD_PROGRAM, OnReload); mdlSystem_setFunction (SYSTEM_UNLOAD_PROGRAM, OnUnload); mdlSystem_setFunction (SYSTEM_EXIT_DESIGN_FILE_STATE, OnExitDesignFile); mdlSystem_setFunction (SYSTEM_NEW_DESIGN_FILE, OnNewDesignFile); mdlSystem_setFunction (SYSTEM_MODEL_CHANGE, OnModelChange); //C and C++ programs start up in the "C" locale. To make them use the //current system locale for everything, say: ::setlocale (LC_ALL,""); // Publish variables that we want to share with MicroStation's // dialog manager void* symbolSet = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, FALSE); if (NULL == symbolSet) { return ERROR; } else if (mdlDialog_publishComplexVariable (symbolSet, "tag_globalvars", "g_globalVars", &g_globalVars)) { return ERROR; } OnReload (argc, argv); return SUCCESS; } }// extern C